Package dev.dirs
Class UserDirectories
- java.lang.Object
-
- dev.dirs.UserDirectories
-
public final class UserDirectories extends java.lang.ObjectUserDirectoriesprovides paths of user-facing standard directories, following the conventions of the operating system the library is running on.Examples
All examples on this page are computed with a user named Alice.
Example of
audioDirvalue in different operating systems:- Linux/BSD:
/home/alice/Music - macOS:
/Users/Alice/Music - Windows:
C:\Users\Alice\Music
- Linux/BSD:
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringaudioDirReturns the path to the user's audio directory.java.lang.StringdesktopDirReturns the path to the user's desktop directory.java.lang.StringdocumentDirReturns the path to the user's document directory.java.lang.StringdownloadDirReturns the path to the user's download directory.java.lang.StringfontDirReturns the path to the user's font directory.java.lang.StringhomeDirReturns the path to the user's home directory.java.lang.StringpictureDirReturns the path to the user's picture directory.java.lang.StringpublicDirReturns the path to the user's public directory.java.lang.StringtemplateDirReturns the path to the user's template directory.java.lang.StringvideoDirReturns the path to the user's video directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static UserDirectoriesget()Creates a newUserDirectoriesinstance.inthashCode()java.lang.StringtoString()
-
-
-
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
-
audioDir
public final java.lang.String audioDir
Returns the path to the user's audio directory.
Platform Value Example Linux/BSD XDG_MUSIC_DIR/home/alice/Music macOS $HOME/Music/Users/Alice/Music Windows {FOLDERID_Music}C:\Users\Alice\Music
-
desktopDir
public final java.lang.String desktopDir
Returns the path to the user's desktop directory.
Platform Value Example Linux/BSD XDG_DESKTOP_DIR/home/alice/Desktop macOS $HOME/Desktop/Users/Alice/Desktop Windows {FOLDERID_Desktop}C:\Users\Alice\Desktop
-
documentDir
public final java.lang.String documentDir
Returns the path to the user's document directory.
Platform Value Example Linux/BSD XDG_DOCUMENTS_DIR/home/alice/Documents macOS $HOME/Documents/Users/Alice/Documents Windows {FOLDERID_Documents}C:\Users\Alice\Documents
-
downloadDir
public final java.lang.String downloadDir
Returns the path to the user's download directory.
Platform Value Example Linux/BSD XDG_DOWNLOAD_DIR/home/alice/Downloads macOS $HOME/Downloads/Users/Alice/Downloads Windows {FOLDERID_Downloads}C:\Users\Alice\Downloads
-
fontDir
public final java.lang.String fontDir
Returns the path to the user's font directory.
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
-
pictureDir
public final java.lang.String pictureDir
Returns the path to the user's picture directory.
Platform Value Example Linux/BSD XDG_PICTURES_DIR/home/alice/Pictures macOS $HOME/Pictures/Users/Alice/Pictures Windows {FOLDERID_Pictures}C:\Users\Alice\Pictures
-
publicDir
public final java.lang.String publicDir
Returns the path to the user's public directory.
Platform Value Example Linux/BSD XDG_PUBLICSHARE_DIR/home/alice/Public macOS $HOME/Public/Users/Alice/Public Windows {FOLDERID_Public}C:\Users\Public
-
templateDir
public final java.lang.String templateDir
Returns the path to the user's template directory.
Platform Value Example Linux/BSD XDG_TEMPLATES_DIR/home/alice/Templates macOS – nullWindows {FOLDERID_Templates}C:\Users\Alice\AppData\Roaming\Microsoft\Windows\Templates
-
videoDir
public final java.lang.String videoDir
Returns the path to the user's video directory.
Platform Value Example Linux/BSD XDG_VIDEOS_DIR/home/alice/Videos macOS $HOME/Movies/Users/Alice/Movies Windows {FOLDERID_Videos}C:\Users\Alice\Videos
-
-
Method Detail
-
get
public static UserDirectories get()
Creates a newUserDirectoriesinstance.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
UserDirectoriesinstance.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-