Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a file in the user's directory in cross-platform Java

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?

like image 510
dalyons Avatar asked Dec 03 '22 14:12

dalyons


1 Answers

System.getProperty("user.home")
like image 78
RichardOD Avatar answered Dec 06 '22 10:12

RichardOD