Package util
Class OS
java.lang.Object
util.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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidrunCommand(String[] command, String errorLog, String output, String runInDir) Executes a command-line command using aProcessBuilder.
-
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.
-