Package dev.dirs

Class BaseDirectories


  • public final class BaseDirectories
    extends java.lang.Object
    BaseDirectories provides paths of user-invisible standard directories, following the conventions of the operating system the library is running on.

    To compute the location of cache, config or data directories for individual projects or applications, use ProjectDirectories instead.

    Examples

    All examples on this page are computed with a user named Alice.

    Example of ProjectDirectories.configDir value in different operating systems:

    • Linux/BSD: /home/alice/.config
    • macOS: /Users/Alice/Library/Preferences
    • Windows: C:\Users\Alice\AppData\Roaming
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String cacheDir
      Returns the path to the user's cache directory.
      java.lang.String configDir
      Returns the path to the user's configuration directory.
      java.lang.String dataDir
      Returns the path to the user's data directory.
      java.lang.String dataLocalDir
      Returns the path to the user's local data directory.
      java.lang.String executableDir
      Returns the path to the user's executable directory.
      java.lang.String homeDir
      Returns the path to the user's home directory.
      java.lang.String preferenceDir
      Returns the path to the user's preference directory.
      java.lang.String runtimeDir
      Returns the path to the user's runtime directory.
    • Field Detail

      • homeDir

        public final java.lang.String homeDir
        Returns the path to the user's home directory.

        Platform Value Example
        Linux/BSD $HOME /home/alice
        macOS $HOME /Users/Alice
        Windows {FOLDERID_Profile} C:\Users\Alice\
      • cacheDir

        public final java.lang.String cacheDir
        Returns the path to the user's cache directory.

        Platform Value Example
        Linux/BSD $XDG_CACHE_HOME or $HOME/.cache /home/alice/.cache
        macOS $HOME/Library/Caches /Users/Alice/Library/Caches
        Windows {FOLDERID_LocalAppData}\cache C:\Users\Alice\AppData\Local
      • configDir

        public final java.lang.String configDir
        Returns the path to the user's configuration directory.

        Platform Value Example
        Linux/BSD $XDG_CONFIG_HOME or $HOME/.config /home/alice/.config
        macOS $HOME/Library/Application Support /Users/Alice/Library/Application Support
        Windows {FOLDERID_RoamingAppData} C:\Users\Alice\AppData\Roaming
      • dataDir

        public final java.lang.String dataDir
        Returns the path to the user's data directory.

        Platform Value Example
        Linux/BSD $XDG_DATA_HOME or $HOME/.local/share /home/alice/.local/share
        macOS $HOME/Library/Application Support /Users/Alice/Library/Application Support
        Windows {FOLDERID_RoamingAppData} C:\Users\Alice\AppData\Roaming
      • dataLocalDir

        public final java.lang.String dataLocalDir
        Returns the path to the user's local data directory.

        Platform Value Example
        Linux/BSD $XDG_DATA_HOME or $HOME/.local/share /home/alice/.local/share
        macOS $HOME/Library/Application Support /Users/Alice/Library/Application Support
        Windows {FOLDERID_LocalAppData} C:\Users\Alice\AppData\Local
      • executableDir

        public final java.lang.String executableDir
        Returns the path to the user's executable directory.

        Platform Value Example
        Linux/BSD $XDG_BIN_HOME or $XDG_DATA_HOME/../bin or $HOME/.local/bin /home/alice/.local/bin
        macOS – null
        Windows – null
      • preferenceDir

        public final java.lang.String preferenceDir
        Returns the path to the user's preference directory.

        Platform Value Example
        Linux/BSD $XDG_CONFIG_HOME or $HOME/.config /home/alice/.config
        macOS $HOME/Library/Preferences /Users/Alice/Library/Preferences
        Windows {FOLDERID_RoamingAppData} C:\Users\Alice\AppData\Roaming
      • runtimeDir

        public final java.lang.String runtimeDir
        Returns the path to the user's runtime directory.

        Platform Value Example
        Linux/BSD $XDG_RUNTIME_DIR /run/user/1001/
        macOS – null
        Windows – null
    • Method Detail

      • get

        public static BaseDirectories get()
        Creates a new BaseDirectories instance.

        The instance is an immutable snapshot of the state of the system at the time this method is invoked. Subsequent changes to the state of the system are not reflected in instances created prior to such a change.

        Returns:
        A new BaseDirectories instance.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object