public class Executor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Executor.StreamHandler
You should use the StreamHandler interface if you would like to process
the output from a process while it is running
|
Constructor and Description |
---|
Executor(java.util.List<java.lang.String> cmdList)
Create a new instance of the Executor.
|
Executor(java.util.List<java.lang.String> cmdList,
java.io.File workingDirectory)
Create a new instance of the Executor
|
Executor(java.lang.String[] cmd)
Create a new instance of the Executor.
|
Modifier and Type | Method and Description |
---|---|
int |
exec()
Execute the command and collect the output.
|
int |
exec(boolean reportExceptions)
Execute the command and collect the output
|
int |
exec(boolean reportExceptions,
Executor.StreamHandler handler)
Execute the command and collect the output
|
java.io.Reader |
getErrorReader()
Get a reader to read the output the process wrote to the error stream.
|
java.io.InputStream |
getErrorStream()
Get an inputstreamto read the output the process wrote to the error stream.
|
java.lang.String |
getErrorString()
Get the output from the process written to the error stream as a string.
|
java.io.Reader |
getOutputReader()
Get a reader to read the output from the process
|
java.io.InputStream |
getOutputStream()
Get an input stream read the output from the process
|
java.lang.String |
getOutputString()
Get the output from the process as a string.
|
static void |
registerErrorHandler() |
public Executor(java.lang.String[] cmd)
cmd
- An array containing the command to executepublic Executor(java.util.List<java.lang.String> cmdList)
cmdList
- A list containing the command to executepublic Executor(java.util.List<java.lang.String> cmdList, java.io.File workingDirectory)
cmdList
- A list containing the command to executeworkingDirectory
- The directory the process should have as the
working directorypublic int exec()
public int exec(boolean reportExceptions)
reportExceptions
- Should exceptions be added to the log or notpublic int exec(boolean reportExceptions, Executor.StreamHandler handler)
reportExceptions
- Should exceptions be added to the log or nothandler
- The handler to handle data from standard outputpublic java.lang.String getOutputString()
public java.io.Reader getOutputReader()
public java.io.InputStream getOutputStream()
public java.lang.String getErrorString()
public java.io.Reader getErrorReader()
public java.io.InputStream getErrorStream()
public static void registerErrorHandler()