user3366706 user3366706 - 2 months ago 5
Apache Configuration Question

Modify Apache CommonConfiguration to not to trim values

I'm using Apache common-configuration library to read properties files for various reasons. My code is given below. By default, it strips the spaces before and after the values, which I want to avoid. Is there a way to do that?

CompositeConfiguration config = new CompositeConfiguration();
PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
URL url = CommonConfig.class.getResource("");
Reader reader = new FileReader(new File(url.getFile()));;

Content of


//both the space before and after must be preserved.


Values are Java escaped1, so use \u0020 for leading and trailing spaces that shouldn't be removed.

Only the first leading and last trailing space needs this, e.g.

key  =  \u0020  value  \u0020

will be the string <sp><sp><sp>value<sp><sp><sp>.


Write CustomPropertiesConfiguration like the example in "Custom properties readers and writers" section in

1) According to source code.