I am not sure spring has an implementation for updating the properties file dynamically.
You can do something like reading the properties file using FileInputStream
into a Properties
object. Then you will be able to update the properties. Later you can write back the properties to the same file using the FileOutputStream
.
// reading the existing properties
FileInputStream in = new FileInputStream("propertiesFile");
Properties props = new Properties();
props.load(in);
in.close();
// writing back the properties after updation
FileOutputStream out = new FileOutputStream("propertiesFile");
props.setProperty("property", "value");
props.store(out, null);
out.close();