Interface OS
public interface OS
Operating system utility functions.
-
Field Summary
Fields -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic StringRuns a bash command with timeout.static ProcessRuns a bash command and redirects output to a file.static ProcessExecutes a shell command in a separate process.static ProcessExecutes a system command in a separate process.static ProcessExecutes a system command in a separate process.static doublegetProperty(String key, double defaultValue) Returns the value of the system property as a double, or the default value if the property is not set or invalid.static floatgetProperty(String key, float defaultValue) Returns the value of the system property as a float, or the default value if the property is not set or invalid.static intgetProperty(String key, int defaultValue) Returns the value of the system property as an integer, or the default value if the property is not set or invalid.static booleanisMacOS()Returns true if the operating system is macOS.static booleanisUnix()Returns true if the operating system is Linux or Unix.static booleanReturns true if the operating system is Windows.Parses a command line into a list of arguments, respecting quoted substrings.Returns the shell command with parsed arguments, respecting quoted substrings.
-
Field Details
-
name
The name of the operating system.
-
-
Method Details
-
isWindows
static boolean isWindows()Returns true if the operating system is Windows.- Returns:
- true if the operating system is Windows.
-
isMacOS
static boolean isMacOS()Returns true if the operating system is macOS.- Returns:
- true if the operating system is macOS.
-
isUnix
static boolean isUnix()Returns true if the operating system is Linux or Unix.- Returns:
- true if the operating system is Linux or Unix.
-
getProperty
Returns the value of the system property as an integer, or the default value if the property is not set or invalid.- Parameters:
key- the name of the system property.defaultValue- the default value to return if the property is not set or invalid.- Returns:
- the integer value of the system property, or the default value if not set or invalid.
-
getProperty
Returns the value of the system property as a float, or the default value if the property is not set or invalid.- Parameters:
key- the name of the system property.defaultValue- the default value to return if the property is not set or invalid.- Returns:
- the float value of the system property, or the default value if not set or invalid.
-
getProperty
Returns the value of the system property as a double, or the default value if the property is not set or invalid.- Parameters:
key- the name of the system property.defaultValue- the default value to return if the property is not set or invalid.- Returns:
- the double value of the system property, or the default value if not set or invalid.
-
parse
-
shell
-
exec
Runs a bash command and redirects output to a file.- Parameters:
command- the command line to run.file- the output file.- Returns:
- the output of the command, or error message if failed.
- Throws:
IOException- when fails to execute the command.
-
exec
Executes a system command in a separate process.- Parameters:
command- the program and its arguments.file- the file to redirect output to.- Returns:
- the process.
- Throws:
IOException- when fails to execute the command.
-
exec
Executes a system command in a separate process.- Parameters:
command- the program and its arguments.outputConsumer- the consumer to handle the output lines from the command.- Returns:
- the process.
- Throws:
IOException- when fails to execute the command.
-
exec
Executes a shell command in a separate process.- Parameters:
command- the command line to run.outputConsumer- the consumer to handle the output lines from the command.- Returns:
- the process.
- Throws:
IOException- when fails to execute the command.
-
exec
-