Package alpine.common.util
Class SystemUtil
java.lang.Object
alpine.common.util.SystemUtil
This class contains a collection of commonly used static methods which
reveal system-wide information. These provide no security-related fixes
to any issue, and are merely available as a convenience.
- Since:
- 1.0
- Author:
- Steve Springett
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturn the bit bucket for the OS.static StringReturn the classpath.static intReturns the number of processor cores available to the JVM.static StringReturn the file separator character that separates components of a file path.static StringReturn the JAVA_HOME environment variable.static StringReturn the temporary directory to be used by Java.static StringReturn the Java vendor.static Runtime.VersionReturn the Java version.static StringReturn the library path.static StringReturn the correct line ender for the host operating system, e.g.static longReturns the number of processor cores available to the JVM.static StringReturn the OS architecture.static StringReturn the name of the host operating system.static StringReturn the OS version.static StringReturn the path separator character used in java.class.path.static StringReturn the home directory of the user executing the current running Java process.static StringReturn the username that is executing the current running Java process.static booleanis32Bit()Return true if the OS architecture model is 32bit.static booleanis64Bit()Return true if the OS architecture model is 64bit.static booleanisLinux()Return true if the host operating system is Linux.static booleanisMac()Return true if the host operating system is OS X.static booleanReturn true if the host operating system is SunOS/Solaris.static booleanisUnix()Return true if the host operating system is Unix/Linux.static booleanReturn true if the host operating system is Windows.
-
Method Details
-
isWindows
public static boolean isWindows()Return true if the host operating system is Windows. Given the currently-supported set of platforms, if this returns false, the OS must be some flavor of UNIX.- Returns:
- True if Windows, False if not
- Since:
- 1.0
-
isMac
public static boolean isMac()Return true if the host operating system is OS X.- Returns:
- True if OS X, False if not
- Since:
- 1.0
-
isLinux
public static boolean isLinux()Return true if the host operating system is Linux.- Returns:
- True if Linux, False if not
- Since:
- 1.0
-
isUnix
public static boolean isUnix()Return true if the host operating system is Unix/Linux. This includes all OS's (except for Mac) which fall in this category.- Returns:
- True if Unix, False if not
- Since:
- 1.0
-
isSolaris
public static boolean isSolaris()Return true if the host operating system is SunOS/Solaris.- Returns:
- True if Solaris, False if not
- Since:
- 1.0
-
getLineEnder
Return the correct line ender for the host operating system, e.g. \r\n for Windows, \n for UNIX.- Returns:
- String containing the line ender for the host operating system
- Since:
- 1.0
-
is32Bit
public static boolean is32Bit()Return true if the OS architecture model is 32bit.- Returns:
- True if 32bit, False if not
- Since:
- 1.0
-
is64Bit
public static boolean is64Bit()Return true if the OS architecture model is 64bit.- Returns:
- True if 64bit, False if not
- Since:
- 1.0
-
getOsName
Return the name of the host operating system.- Returns:
- String containing the name of the host operating system
- Since:
- 1.0
-
getOsArchitecture
Return the OS architecture.- Returns:
- String containing the OS architecture
- Since:
- 1.0
-
getOsVersion
Return the OS version.- Returns:
- String containing the OS version
- Since:
- 1.0
-
getFileSeparator
Return the file separator character that separates components of a file path. This is "/" on UNIX and "\" on Windows.- Returns:
- String containing the file separator character
- Since:
- 1.0
-
getPathSeparator
Return the path separator character used in java.class.path.- Returns:
- String containing the path separator character
- Since:
- 1.0
-
getUserName
Return the username that is executing the current running Java process.- Returns:
- String containing the username that is executing the current running Java process
- Since:
- 1.0
-
getUserHome
Return the home directory of the user executing the current running Java process.- Returns:
- String containing the home directory of the user executing the current running Java process
- Since:
- 1.0
-
getJavaVendor
Return the Java vendor.- Returns:
- String containing the Java vendor
- Since:
- 1.0
-
getJavaVersion
Return the Java version.- Returns:
- JavaVersion containing Java version information
- Since:
- 1.0
-
getJavaHome
Return the JAVA_HOME environment variable.- Returns:
- String containing the JAVA_HOME environment variable
- Since:
- 1.0
-
getJavaTempDir
Return the temporary directory to be used by Java.- Returns:
- String containing the temporary directory to be used by Java
- Since:
- 1.0
-
getClassPath
Return the classpath.- Returns:
- String containing the classpath
- Since:
- 1.0
-
getLibraryPath
Return the library path.- Returns:
- String containing the library path
- Since:
- 1.0
-
getBitBucket
Return the bit bucket for the OS. '/dev/null' for Unix and 'NUL' for Windows.- Returns:
- a String containing the bit bucket
- Since:
- 1.0
-
getCpuCores
public static int getCpuCores()Returns the number of processor cores available to the JVM.- Returns:
- an integer of the number of processor core
- Since:
- 1.0.0
-
getMaxMemory
public static long getMaxMemory()Returns the number of processor cores available to the JVM.- Returns:
- an integer of the number of processor core
- Since:
- 1.9.0
-