Is there a platform-independent way to get a path to store program data in Java?
This is surely a very basic question but I can't seem to find the answer anywhere. I am looking for a path to store user data such as user preferences or historical data input. On Windows we would normally store it in C:\Program Files\APPNAME
, C:\Program Files (x86)\APPNAME
or C:\ProgramData\APPNAME
depending on the OS and architecture. On Unix we could store preferences in /etc/APPNAME
or /opt/APPNAME
depending on the context. On Mac we have a special cabinet to store program's data. In java, how do we get a location like this in a platform-independent way?