0
am with an application that works with Properties configuration files.
Imagine that I have a file with 100 properties and in a certain part of my code, I want to rewrite only 1 of these properties, have to do it without losing the others that are already there ?
Below follows code I am testing and trying to get the result above.
public class propriedades {
public static void main(String[] args) {
Properties properties = new Properties();
// setando as propriedades(key) e os seus valores(value)
properties.setProperty("jdbc.user", "sysdba1");
properties.setProperty("jdbc.pass", "masterkey");
try {
// Criamos um objeto FileOutputStream
FileOutputStream fos = new FileOutputStream("C:/jdbc.properties");
// grava os dados no arquivo
properties.store(fos, "FILE JDBC PROPERTIES:");
// fecha o arquivo
fos.close();
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
}
You have to load the properties file first (if I’m not mistaken with properties.load()) and after you change the save Property (I don’t remember how you do it).
– Piovezan