views:

197

answers:

4

I have a Java application that runs on Mac and Windows, directly off a CD/DVD with no installation. Now, I need to store a file containing per-user data (think favourites etc.) somewhere on the local file system, so that it can be written to.

So, where do you think is a good location for this file? I am thinking something like:

<USER_DOCUMENTS_AND_SETTINGS>/application data/myapp/favourites.db for windows <USER_HOME_DIR>/.myapp/favourites.db for mac/nix

Thoughts? And does anyone know the best way to determine these paths within Java?

+4  A: 
System.getProperty("user.home")
RichardOD
and I just append "/Application Data" to that? does that folder name ever change depending on localization?
dalyons
System.getProperty("user.home") + File.separator + "Application Data";
RichardOD
+1  A: 

As well as user.home, the following is useful for more temporary file storage:

System.getProperty("java.io.tmpdir")
oxbow_lakes
+1  A: 

Use the Java Preferences API, designed specifically to store user preferences values in a platform independent way we all like. Java will take care of saving them and retrieving from the file or other backing store depending on the OS.

These tutorials can get you going

n002213f
I am already using the preference API for some settings - but this is a *file* that needs storing(db file), not a string setting.
dalyons
my take was that *favourites.db* contains key-value pairs for settings.
n002213f
A: 

You can consider storing the data at Roaming directory under Windows.

denis.zhdanov