dev.dirs
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.
All examples on this page are computed with a user named Alice.
Example of ProjectDirectories.configDir value in different operating systems:
/home/alice/.config/Users/Alice/Library/PreferencesC:\Users\Alice\AppData\Roaming| Modifier and Type | Field and 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.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
static BaseDirectories |
get()
Creates a new
BaseDirectories instance. |
int |
hashCode() |
java.lang.String |
toString() |
public final java.lang.String homeDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $HOME |
/home/alice |
| macOS | $HOME |
/Users/Alice |
| Windows | {FOLDERID_Profile} |
C:\Users\Alice\ |
public final java.lang.String cacheDir
| 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 |
public final java.lang.String configDir
| 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 |
public final java.lang.String dataDir
| 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 |
public final java.lang.String dataLocalDir
| 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 |
public final java.lang.String executableDir
| 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 |
public final java.lang.String preferenceDir
| 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 |
public final java.lang.String runtimeDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_RUNTIME_DIR |
/run/user/1001/ |
| macOS | – | null |
| Windows | – | null |
public static BaseDirectories get()
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.
BaseDirectories instance.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object