public class CommandRunner
extends java.lang.Object
Constructor and Description |
---|
CommandRunner(util.runtime.CommandBuilder command)
Creates a new instance to run a given process.
|
Modifier and Type | Method and Description |
---|---|
<T> util.object.Pair<java.lang.Integer,T> |
exec(java.util.function.Function<java.io.InputStream,T> outputReader)
Runs the process redirecting both its error and output streams to an
input stream that is given to a consumer to read.
|
int |
exec(java.nio.file.Path outputFile)
Runs the process redirecting both its error and output streams to the
specified file.
|
public CommandRunner(util.runtime.CommandBuilder command)
command
- the command to start the process.java.lang.NullPointerException
- if the argument is null
.public int exec(java.nio.file.Path outputFile) throws java.io.IOException, java.lang.InterruptedException
outputFile
- the file to redirect the process's streams to.java.io.IOException
- if an I/O error occurs while running the process.java.lang.InterruptedException
- if the current thread is interrupted before
the spawned process terminates.public <T> util.object.Pair<java.lang.Integer,T> exec(java.util.function.Function<java.io.InputStream,T> outputReader) throws java.io.IOException, java.lang.InterruptedException
T
- any type.outputReader
- reads the process's output.java.io.IOException
- if an I/O error occurs while running the process.java.lang.InterruptedException
- if the current thread is interrupted before
the spawned process terminates.