Storing a file in a user directory in cross-platform Java

I have a Java application that runs on Mac and Windows, directly from a CD / DVD without installation. Now I need to save a file containing data for each user (I think, favorites, etc.) Somewhere in the local file system so that it can be written.

So, what do you think is a good place for this file? I think something like:

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

Thoughts? And does anyone know a better way to define these paths in Java?

+3
source share
4 answers
System.getProperty("user.home")
+7
source

As well user.home, for longer file storage, the following is useful:

System.getProperty("java.io.tmpdir")
+3
0

- Windows.

0

Source: https://habr.com/ru/post/1720155/


All Articles