I use the following code to write data to a properties file
public void WritePropertiesFile(String key, String data) { Properties configProperty = new Properties(); configProperty.setProperty(key, data); File file = new File("D:\\Helper.properties"); FileOutputStream fileOut = new FileOutputStream(file,true); configProperty.store(fileOut, "sample properties"); fileOut.close(); } I am calling the above method 3 times as follows: help.WritePropertiesFile("appwrite1","write1"); help.WritePropertiesFile("appwrite2","write2"); help.WritePropertiesFile("appwrite3","write3");
However, the data in the Helper.properties file is displayed as follows:
#sample properties
I want the data to be added to existing data and not want to duplicate the data, namely:
appwrite3=write3 appwrite2=write2 appwrite1=write1
Please suggest how to do this?
source share