Hi this post is related to my old post. But in this I have achieved much.
I am using FileBasedConfigurationBuilder
class of Apache common configuration API for updating property file in java. Below is my code:
FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(
PropertiesConfiguration.class)
.configure(new Parameters().properties().setFileName("test.properties")
.setThrowExceptionOnMissing(true));
PropertiesConfiguration config = builder.getConfiguration();
config.setProperty("Id", "3");
builder.save();
System.out.println("config.properties updated Successfully!!");
Now one of my key have value like
C\://ABC.net\\:1010
.
After modification it becomes
C\\://ABC.net\\:1010
. Means it single backslash is converting to two single backslash. Previously I was using common configuration jar 1.10 it that forwardslash also getting change. Now I have used common configuration version
commons-configuration2-2.0.jar. By this version only problem in backslash.
Can any one suggested how to avoid this? I need that after modification single backslash should not convert to doublebackslash.Please note that I don't want to change the property file.
I was following below post to reach till here. PropertiesConfiguration - Using "/" in Property value