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

前端 未结 4 1100
遇见更好的自我
遇见更好的自我 2020-12-21 05:52

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 e

相关标签:
4条回答
  • 2020-12-21 06:12

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

    System.getProperty("java.io.tmpdir")
    
    0 讨论(0)
  • 2020-12-21 06:17

    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

    0 讨论(0)
  • 2020-12-21 06:26
    System.getProperty("user.home")
    
    0 讨论(0)
  • 2020-12-21 06:26

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

    0 讨论(0)
提交回复
热议问题