I have a Swing Frame with some text-fields which displays the current values in the Properties file. Once I modify these properties in the text-field it should be saved back to the properties file. The properties which I have are database connection parameters. My connection parameters are as follows
driver--org.postgresql.Driver
url--jdbc:postgresql://localhost/bank
user--postgres
password--aaa
But when it updates, in the url field, where ever there is a ':', it adds a '\'
like URL2=jdbc\:postgresql\://localhost/bank. How can I avoid this? I tried printing the contents before setting the Properties file and then it is ok.
I printed the String before setting the properties, there it is coming right;
org.postgresql.Driver **jdbc:postgresql://localhost/bank**postgres**aaa
Can someone please help me. Thanks in Advance
public static void update(String driver,String url, String user,String password) throws SecurityException, IOException{
System.out.println(driver+" **"+url+"**"+user+"**"+password);
FileInputStream in = new FileInputStream("evaluator.properties");
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream("evaluator.properties");
props.setProperty("Driver2", driver);
props.setProperty("URL2", url);
props.setProperty("Login2", user);
props.setProperty("Password2", password);
props.store(out, null);
out.close();
}
Propertiesclass) how do they look?props.list(System.err);directly after yourprops.load(in);line, you can verify that after reloading the properties look fine