dev.dirs
public final class UserDirectories extends java.lang.Object
UserDirectories provides paths of user-facing standard directories, following the conventions of the operating system the library is running on.
All examples on this page are computed with a user named Alice.
Example of audioDir value in different operating systems:
/home/alice/Music/Users/Alice/MusicC:\Users\Alice\Music| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
audioDir
Returns the path to the user's audio directory.
|
java.lang.String |
desktopDir
Returns the path to the user's desktop directory.
|
java.lang.String |
documentDir
Returns the path to the user's document directory.
|
java.lang.String |
downloadDir
Returns the path to the user's download directory.
|
java.lang.String |
fontDir
Returns the path to the user's font directory.
|
java.lang.String |
homeDir
Returns the path to the user's home directory.
|
java.lang.String |
pictureDir
Returns the path to the user's picture directory.
|
java.lang.String |
publicDir
Returns the path to the user's public directory.
|
java.lang.String |
templateDir
Returns the path to the user's template directory.
|
java.lang.String |
videoDir
Returns the path to the user's video directory.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
static UserDirectories |
get()
Creates a new
UserDirectories 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 audioDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_MUSIC_DIR |
/home/alice/Music |
| macOS | $HOME/Music |
/Users/Alice/Music |
| Windows | {FOLDERID_Music} |
C:\Users\Alice\Music |
public final java.lang.String desktopDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_DESKTOP_DIR |
/home/alice/Desktop |
| macOS | $HOME/Desktop |
/Users/Alice/Desktop |
| Windows | {FOLDERID_Desktop} |
C:\Users\Alice\Desktop |
public final java.lang.String documentDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_DOCUMENTS_DIR |
/home/alice/Documents |
| macOS | $HOME/Documents |
/Users/Alice/Documents |
| Windows | {FOLDERID_Documents} |
C:\Users\Alice\Documents |
public final java.lang.String downloadDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_DOWNLOAD_DIR |
/home/alice/Downloads |
| macOS | $HOME/Downloads |
/Users/Alice/Downloads |
| Windows | {FOLDERID_Downloads} |
C:\Users\Alice\Downloads |
public final java.lang.String fontDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_DATA_HOME/fonts or $HOME/.local/share/fonts |
/home/alice/.local/share/fonts |
| macOS | $HOME/Library/Fonts |
/Users/Alice/Library/Fonts |
| Windows | – | null |
public final java.lang.String pictureDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_PICTURES_DIR |
/home/alice/Pictures |
| macOS | $HOME/Pictures |
/Users/Alice/Pictures |
| Windows | {FOLDERID_Pictures} |
C:\Users\Alice\Pictures |
public final java.lang.String publicDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_PUBLICSHARE_DIR |
/home/alice/Public |
| macOS | $HOME/Public |
/Users/Alice/Public |
| Windows | {FOLDERID_Public} |
C:\Users\Public |
public final java.lang.String templateDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_TEMPLATES_DIR |
/home/alice/Templates |
| macOS | – | null |
| Windows | {FOLDERID_Templates} |
C:\Users\Alice\AppData\Roaming\Microsoft\Windows\Templates |
public final java.lang.String videoDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | XDG_VIDEOS_DIR |
/home/alice/Videos |
| macOS | $HOME/Movies |
/Users/Alice/Movies |
| Windows | {FOLDERID_Videos} |
C:\Users\Alice\Videos |
public static UserDirectories get()
UserDirectories 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.
UserDirectories 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