1) The contents of the properties file should look like this:
key1=value1 key2=value2
2) You open the file in add mode, this is wrong. It should be:
new FileOutputStream(file);
3) Close out1 explicitly, Properties.store API:
The output stream remains open after this method returns.
If you do not want to use Properties.store, you can directly write "Properties"
PrintWriter pw = new PrintWriter("test.properties"); for(Entry e : props.entrySet()) { pw.println(e); } pw.close();
source share