Class OperatingSystem


  • public class OperatingSystem
    extends java.lang.Object
    Utilities for working with operating system-specific attributes.
    Author:
    Garret Wilson
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String JAVA_IO_TMPDIR_PROPERTY
      The temporary directory name.
      static java.lang.String LINE_SEPARATOR_PROPERTY
      The property specifying the line separator character for the platform.
      static java.lang.String OS_ARCH_PROPERTY
      The operating system architecture.
      static java.lang.String OS_NAME_PROPERTY
      The name of the operating system.
      static java.lang.String OS_VERSION_PROPERTY
      The operating system version.
      static java.lang.String USER_DIR_PROPERTY
      The property for the user's current working directory.
      static java.lang.String USER_HOME_PROPERTY
      The property for the user's home directory.
      static java.lang.String USER_NAME_PROPERTY
      The user name property.
      static java.lang.String WINDOWS
      The string, "windows", which is a case-insensitive substring of a Windows operating system identification string.
    • Constructor Summary

      Constructors 
      Constructor Description
      OperatingSystem()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getLineSeparator()
      Returns the system line separator string.
      static java.nio.file.Path getTempDirectory()
      Returns the system temporary directory
      static java.nio.file.Path getUserHomeDirectory()
      Returns the home directory of the user.
      static java.nio.file.Path getWorkingDirectory()
      Returns the current directory of the user.
      static boolean isWindowsOS()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LINE_SEPARATOR_PROPERTY

        public static final java.lang.String LINE_SEPARATOR_PROPERTY
        The property specifying the line separator character for the platform.
        See Also:
        Constant Field Values
      • JAVA_IO_TMPDIR_PROPERTY

        public static final java.lang.String JAVA_IO_TMPDIR_PROPERTY
        The temporary directory name.
        See Also:
        Constant Field Values
      • OS_NAME_PROPERTY

        public static final java.lang.String OS_NAME_PROPERTY
        The name of the operating system.
        See Also:
        Constant Field Values
      • OS_ARCH_PROPERTY

        public static final java.lang.String OS_ARCH_PROPERTY
        The operating system architecture.
        See Also:
        Constant Field Values
      • OS_VERSION_PROPERTY

        public static final java.lang.String OS_VERSION_PROPERTY
        The operating system version.
        See Also:
        Constant Field Values
      • USER_NAME_PROPERTY

        public static final java.lang.String USER_NAME_PROPERTY
        The user name property.
        See Also:
        Constant Field Values
      • USER_HOME_PROPERTY

        public static final java.lang.String USER_HOME_PROPERTY
        The property for the user's home directory.
        See Also:
        Constant Field Values
      • USER_DIR_PROPERTY

        public static final java.lang.String USER_DIR_PROPERTY
        The property for the user's current working directory.
        See Also:
        Constant Field Values
      • WINDOWS

        public static final java.lang.String WINDOWS
        The string, "windows", which is a case-insensitive substring of a Windows operating system identification string.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OperatingSystem

        public OperatingSystem()
    • Method Detail

      • getLineSeparator

        public static java.lang.String getLineSeparator()
                                                 throws java.lang.SecurityException
        Returns the system line separator string.
        Returns:
        The the system line separator string.
        Throws:
        java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to this system property.
        See Also:
        LINE_SEPARATOR_PROPERTY
      • getUserHomeDirectory

        public static java.nio.file.Path getUserHomeDirectory()
                                                       throws java.lang.SecurityException
        Returns the home directory of the user.
        Returns:
        The user home directory.
        Throws:
        java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to this system property.
        See Also:
        USER_HOME_PROPERTY
      • getTempDirectory

        public static java.nio.file.Path getTempDirectory()
                                                   throws java.lang.SecurityException
        Returns the system temporary directory
        Returns:
        The system temporary directory directory.
        Throws:
        java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to this system property.
        See Also:
        JAVA_IO_TMPDIR_PROPERTY
      • getWorkingDirectory

        public static java.nio.file.Path getWorkingDirectory()
                                                      throws java.lang.SecurityException
        Returns the current directory of the user.
        Returns:
        The user's current working directory.
        Throws:
        java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to this system property.
        See Also:
        USER_DIR_PROPERTY
      • isWindowsOS

        public static boolean isWindowsOS()
        Returns:
        true if the operating system is a version of Windows.
        Throws:
        java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to this system property.
        See Also:
        OS_NAME_PROPERTY