inifiles with serialize ??
Hello,
I need to store some variables on harddisk in order to restore their
values in successive sessions.
I took this simple aproach:
Inifile as map, loaded at the startup.
- - - - - - - - - - - - - - - - - - - -
Map<String, String> ini=new HashMap<String,String>();
try {
ObjectInputStream input=new ObjectInputStream(new
FileInputStream(inifile));
ini=(HashMap<String,String>)input.readObject();
} catch (IOException e) {}
catch (ClassNotFoundException e) {}
- - - - - - - - - - - - - - - - - - - -
Changes during the session
ini.put("key","value");
Storing at closing app:
- - - - - - - - - - - - - - - - - - - -
public void windowClosing(WindowEvent e) {
try {
ObjectOutputStream output=new ObjectOutputStream(
new FileOutputStream(inifile));
output.writeObject(ini);
} catch (IOException ex) {}
- - - - - - - - - - - - - - - - - - - -
My question is:
How realible is this approach with respect to future changes of Java?
The byte-representation of Map might change ?
Juergen