I have designed a Java application and I want to save its last window state and some other settings like date format. I currently save window state to "config.ini" file and it works fine for this code.
private void saveConfig() {
try {
Properties properties = new Properties();
properties.setProperty("windowstate", String.valueOf(this.getExtendedState()));
properties.store(new FileOutputStream("./data/config.ini"), null);
} catch (Exception e) {
}
}
But I want to save some other settings too. For that can I update individual parameters of this config.ini file? (Currently there is only "windowstate", in case there is something like date format, last used email address etc...)
My current file is like this
#Sun Jul 07 22:19:35 IST 2013
windowstate=0
E.g. If config.ini file is like this
#Sun Jul 07 22:19:35 IST 2013
windowstate=0
dateformat=yyyy-MM-dd
lastmailaddress=abcd@mail.com
can I update only "lastmailaddress" without affecting others? and how? Currently my code is overwriting this file.
Thank you.