@Test public void shouldStorePropertiesWithEsacpeChar() { Properties props = new Properties(); props.put("inputFolder", "/home/karel4;/one"); props.put("outputFolder", "/home/karel4;/two"); props.put("name", ";- PROCESS NAME - ;"); String line = PropertiesStoreUtils.storeProperties(props); Assert.assertEquals("inputFolder=/home/karel4\\;/one;name=\\;- PROCESS NAME - \\;;outputFolder=/home/karel4\\;/two", line); }
public static String storeProperties(Properties properties) { StringWriter writer = new StringWriter(); Object[] keys = properties.keySet().toArray(); for (int i = 0,ll=keys.length; i < ll; i++) { String key = keys[i].toString(); writer.write(StringUtils.escape( key.trim(), '\\', ';')); writer.write("="); writer.write(StringUtils.escape( properties.getProperty(key), '\\', ';')); if (i<ll-1) { writer.write(";"); } } return writer.toString(); }
PropertiesStoreUtils { public static String storeProperties(Properties properties) { StringWriter writer = new StringWriter(); Object[] keys = properties.keySet().toArray(); for (int i = 0,ll=keys.length; i < ll; i++) { String key = keys[i].toString(); writer.write(StringUtils.escape( key.trim(), '\\', ';')); writer.write("="); writer.write(StringUtils.escape( properties.getProperty(key), '\\', ';')); if (i<ll-1) { writer.write(";"); } } return writer.toString(); } }
PropertiesStoreUtils { public static String storeProperties(Properties properties) { StringWriter writer = new StringWriter(); Object[] keys = properties.keySet().toArray(); for (int i = 0,ll=keys.length; i < ll; i++) { String key = keys[i].toString(); writer.write(StringUtils.escape( key.trim(), '\\', ';')); writer.write("="); writer.write(StringUtils.escape( properties.getProperty(key), '\\', ';')); if (i<ll-1) { writer.write(";"); } } return writer.toString(); }  }
PropertiesStoreUtils { public static String storeProperties(Properties properties) { StringWriter writer = new StringWriter(); Object[] keys = properties.keySet().toArray(); for (int i = 0,ll=keys.length; i < ll; i++) { String key = keys[i].toString(); writer.write(StringUtils.escape( key.trim(), '\\', ';')); writer.write("="); writer.write(StringUtils.escape( properties.getProperty(key), '\\', ';')); if (i<ll-1) { writer.write(";"); } } return writer.toString(); }  static String storeProperties(Properties properties); static Properties loadProperties(String str); }
PropertiesStoreUtils { public static String storeProperties(Properties properties) { StringWriter writer = new StringWriter(); Object[] keys = properties.keySet().toArray(); for (int i = 0,ll=keys.length; i < ll; i++) { String key = keys[i].toString(); writer.write(StringUtils.escape( key.trim(), '\\', ';')); writer.write("="); writer.write(StringUtils.escape( properties.getProperty(key), '\\', ';')); if (i<ll-1) { writer.write(";"); } } return writer.toString(); }  static String storeProperties(Properties properties); static Properties loadProperties(String str);  }