Package dev.dirs

Class UserDirectories


  • 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.

    Examples

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

    Example of audioDir value in different operating systems:

    • Linux/BSD: /home/alice/Music
    • macOS: /Users/Alice/Music
    • Windows: C:\Users\Alice\Music
    • Field Summary

      Fields 
      Modifier and Type Field 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.
    • 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 – null
        Windows {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 new 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.

        Returns:
        A new UserDirectories 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