public abstract class Executor
extends java.lang.Object
Process
which takes care of the stream output and so on. It's not completely
general purpose, it's designed for running little shell commands -
if you try to run something which spews out a huge amount of output
you could have trouble.Constructor | Description |
---|---|
Executor() |
Modifier and Type | Method | Description |
---|---|---|
static Executor |
createExecutor(java.lang.String line) |
Returns an executor which executes a single command line.
|
static Executor |
createExecutor(java.lang.String[] argv) |
Returns an executor which executes a command made of words.
|
int |
executeSynchronously(boolean isCapture) |
Calls
getProcess() and attempts to execute it synchronously. |
java.lang.String |
getErr() |
Returns the standard error which resulted from running the process,
if execution was done in capturing mode.
|
abstract java.lang.String |
getLine() |
Returns a representation of the command line executed.
|
java.lang.String |
getOut() |
Returns the standard output which resulted from running the process,
if execution was done in capturing mode.
|
abstract java.lang.Process |
getProcess() |
Returns a system process to be executed.
|
java.lang.String |
toString() |
public abstract java.lang.Process getProcess() throws java.io.IOException
java.io.IOException
public abstract java.lang.String getLine()
public java.lang.String getOut()
public java.lang.String getErr()
public int executeSynchronously(boolean isCapture) throws java.io.IOException, java.lang.InterruptedException
getProcess()
and attempts to execute it synchronously.
Can be run only once on this object.
If isCapture
is set true, the getOut()
and
getErr()
methods can be used after this call to get
the results from stdout and stderr. Otherwise, the process
output streams go to the JVM's stdout/stderr.
isCapture
- true to capture output and return it as
the outcome message, false to let it go to stdoutjava.io.IOException
java.lang.InterruptedException
public java.lang.String toString()
toString
in class java.lang.Object
public static Executor createExecutor(java.lang.String line)
line
- shell command linepublic static Executor createExecutor(java.lang.String[] argv)
argv
- argument vectorCopyright ? 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.