java.lang.Object
net.automatalib.common.util.process.ProcessUtil
Utility class for invoking system processes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intinvokeProcess(String[] commandLine) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(String[] commandLine, Reader input) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(String[] commandLine, Reader input, OutputStream stdOutConsumer, OutputStream stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(String[] commandLine, Reader input, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(String[] commandLine, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(List<String> commandLine) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(List<String> commandLine, @Nullable Reader input, OutputStream stdOutConsumer, OutputStream stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(List<String> commandLine, @Nullable Reader input, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(List<String> commandLine, Reader input) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.static intinvokeProcess(List<String> commandLine, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) Runs the given set of command line arguments as a system process and returns the exit value of the spawned process.
-
Method Details
-
invokeProcess
Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Discards any output of the process.- Parameters:
commandLine- the list of command line arguments to run- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Discards any output of the process.- Parameters:
commandLine- the list of command line arguments to run- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(String[] commandLine, Reader input) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Discards any output of the process.- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the program- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(List<String> commandLine, Reader input) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Discards any output of the process.- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the program- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(String[] commandLine, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Outputs of the process (normal and error) are passed to the respectiveconsumers.- Parameters:
commandLine- the list of command line arguments to runstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(List<String> commandLine, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Outputs of the process (normal and error) are passed to the respectiveconsumers such that each line results in a separate call toConsumer.accept(Object).- Parameters:
commandLine- the list of command line arguments to runstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(String[] commandLine, Reader input, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Outputs of the process (normal and error) are passed to the respectiveconsumers such that each line results in a separate call toConsumer.accept(Object).- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the programstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if an exception occurred during process exception
-
invokeProcess
public static int invokeProcess(List<String> commandLine, @Nullable Reader input, Consumer<String> stdOutConsumer, Consumer<String> stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Outputs of the process (normal and error) are passed to the respectiveconsumers such that each line results in a separate call toConsumer.accept(Object).- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the programstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if the process is interrupted prior to finishing
-
invokeProcess
public static int invokeProcess(String[] commandLine, Reader input, OutputStream stdOutConsumer, OutputStream stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Outputs of the process (normal and error) are passed to the respectiveconsumers.- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the programstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if the process is interrupted prior to finishing
-
invokeProcess
public static int invokeProcess(List<String> commandLine, @Nullable Reader input, OutputStream stdOutConsumer, OutputStream stdErrConsumer) throws IOException, InterruptedException Runs the given set of command line arguments as a system process and returns the exit value of the spawned process. Additionally, allows one to supply an input stream to the invoked program. Outputs of the process (normal and error) are passed to the respectiveconsumers.- Parameters:
commandLine- the list of command line arguments to runinput- the input passed to the programstdOutConsumer- the consumer for the program's standard outputstdErrConsumer- the consumer for the program's error output- Returns:
- the exit code of the process
- Throws:
IOException- if an exception occurred while reading the process' outputs, or writing the process' inputsInterruptedException- if the process is interrupted prior to finishing
-