Hi,
I store my properties to a file after i populated them with strings using the setProperty(String key, String value) method. However, it keeps overwriting the properties that i have not changed during this action. So I first loaded the properties with an input stream of the file. Didn't help neither. How do I need to store correctly without loosing the other existing entries in the properties file?
I store my properties to a file after i populated them with strings using the setProperty(String key, String value) method. However, it keeps overwriting the properties that i have not changed during this action. So I first loaded the properties with an input stream of the file. Didn't help neither. How do I need to store correctly without loosing the other existing entries in the properties file?
Code:
Properties prop = new Properties();
String propFile = "User.properties";
FileOutputStream out = new FileOutputStream(propFile);
Date d = new Date();
try {
prop.load(new FileInputStream(propFile));
prop.setProperty("Room", "23");
prop.store(out, "Saved on " + d.toString());
} catch (IOException ex) {
Logger.getLogger(JPanelUserSettings.class.getName()).log(Level.SEVERE, null, ex);
}