I am trying to update properties file as below.
Properties props = new Properties();
FileInputStream in = new FileInputStream(filepath);
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(filepath);
props.setProperty(key, value);
props.store(out,"fileupdated");
out.close();
But always I notice that newly added properties are added some where in middle of the file and I want it to be added only at the end. Please advise how should I resolve this.
Also, I have requirement to update core properties file. So in case if there are any issues updating the properties file, my server will stop running. Just because even a miss of single existing property will impact. So i am planning to create a temp file and if writing is succesfull i will rename to original file. PLease let me know if there are any other better approaches.