Package utility
Class OS
java.lang.Object
utility.OS
Utility class for operating system-related functionalities.
This class provides methods for executing command-line commands and handling file and directory operations. It is designed to facilitate interaction with the underlying operating system from within the application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
runCommand
(String[] command, String errorLog, String output, String runInDir) Executes a command-line command using aProcessBuilder
.
-
Constructor Details
-
OS
public OS()
-
-
Method Details
-
runCommand
public static void runCommand(String[] command, String errorLog, String output, String runInDir) throws RuntimeException Executes a command-line command using aProcessBuilder
.This method runs the specified command in a separate process. It allows redirecting error logs, output, and setting the working directory for the process.
- Parameters:
command
- An array of strings representing the command and its arguments.errorLog
- The file path to redirect error logs. If empty, errors are not redirected.output
- The file path to redirect standard output. If empty, output is not redirected.runInDir
- The directory in which the command should be executed. If empty, the default directory is used.- Throws:
RuntimeException
- If an error occurs while executing the command.
-