I have an issue.
I have a properties file. I want to store some values in that file and will implement in the code whenever it is required. Is there any way to do t
Load the properties file using java.util.Properties.
Code snippet -
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream("xyz.properties");
prop.load(in);
It provides Properties#setProperty(java.lang.String, java.lang.String) which helps to add new property.
Code snippet -
prop.setProperty("newkey", "newvalue");
This new set you can save using Properties#store(java.io.OutputStream, java.lang.String)
Code Snippet -
prop.store(new FileOutputStream("xyz.properties"), null);