Basically, I have to overwrite a certain property in a .properties file through a Java app, but when I use Properties.setProperty() and Properties.Store() it overwrites the whole file rather than just that one property.
I've tried constructing the FileOutputStream with append = true, but with that it adds another property and doesn't delete/overwrite the existing property.
How can I code it so that setting one property overwrites that specific property, without overwriting the whole file?
Edit: I tried reading the file and adding to it. Here's my updated code:
FileOutputStream out = new FileOutputStream("file.properties");
FileInputStream in = new FileInputStream("file.properties");
Properties props = new Properties();
props.load(in);
in.close();
props.setProperty("somekey", "somevalue");
props.store(out, null);
out.close();