Karsten Wutzke schrieb:
I wish to save some user data (editable via GUI) on a per user basis.
Is there any nice mechanism in Java that puts such info into an
appropriate place? If I have to do that manually, what would be a nice
place to save some small files with bothering the user? Or shall I
force every user to specify a directory?
Sounds like you need java.util.prefs.Preferences.
You can get a handle to the user's preferences by:
Preferences prefs =
Preferences.userNodeForPackage(my.package.Main.class);
Java keeps the user's preferences in a platform-specific place:
(*) for Windows: in a certain user-specific branch of the registry
(*) for Unix/Linux: in a certain hidden file in the user's home dir.
But you don't have to care about those details.
You read/write specific key/value like this:
String value = prefs.get(key);
prefs.get(key, value);
For more details see the API docs
<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>
<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html#userNodeForPackage(java.lang.Class)>
I hadn't seen this before (where have I been?). Where does it store