Skip to content
Advertisement

How to create properties without white spaces between separator using org.apache.commons.configuration.PropertiesConfiguration?

Need to write a properties file using org.apache.commons.configuration.PropertiesConfiguration and it should have a format like variablename=variablevalue without having whitespaces between the separator. Is there a way to achieve that using apache commons-configuration?

My current implementation :

PropertiesConfiguration conf = new PropertiesConfiguration("test.properties");
conf.setProperty("key1","value1");
conf.save();

Result :

key1 = value1

Expected Result :

key1=value1

Advertisement

Answer

Docs are here: https://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_properties.html

Untested but I imagine this does it:

conf.getLayout().setGlobalSeparator("=");
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement