1. 14
  • A tiny library (8kB)
  • with minimal public API (3 classes, 6 methods, 21 fields)
  • for convenient access to standardized directories
  • on Linux, Windows (≥ 7) and macOS
  • running on the JVM

The library provides the location of directories by leveraging the mechanisms defined by

  1.  

  2. 9

    The idea is that application authors – instead of just dumping their application’s data into ~/.barapp – can use a small API that returns the appropriate directories for each different kind of data an application might save to disk on each operating system:

    import io.github.soc.directories.ProjectDirectories
    val myProjDirs =
      ProjectDirectories.fromFullyQualifiedProjectName("org.foocorp.BarApp")
    myProjDirs.projectConfigDir
    // Linux:   ~/.config/barapp/
    // Windows: C:/Users/SomeUser/AppData/BarApp/
    // macOS:   ~/Library/Preferences/org.foocorp.BarApp/
    
    1. 6

      In other parts of the world:

      csharp> Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
      "/home/calvin/Music"
      csharp> Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
      "/home/calvin/.config"
      
      > Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
      "C:\\Users\\Calvin\\Music"
      > Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
      "C:\\Users\\Calvin\\AppData\\Roaming"
      
      1. 4

        True. :-)

        I’m kind of scared of proposing it as an addition to the JDK, because usually additions to Java end up being either completely over-engineered or broken (or both).