|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.fife.io.ProcessRunner
public class ProcessRunner
Runs an external process (a program, batch file, shell script, etc.) as safely as possible.
Constructor Summary | |
---|---|
ProcessRunner(java.lang.String[] commandLine)
Constructor. |
Method Summary | |
---|---|
boolean |
getAppendEnvironmentVars()
Returns whether any extra environment variables defined for this process to run with should be appended to the parent process's environment (as opposed to overwriting it). |
java.lang.String |
getCommandLineString()
Returns the command line this external process runner will run as a string. |
java.io.File |
getDirectory()
Returns the directory to run the process in. |
java.util.Map<java.lang.String,java.lang.String> |
getEnvironmentVars()
Returns any extra environment variables defined for this process to run with. |
java.lang.Throwable |
getLastError()
Returns the last error thrown when trying to run a process, or null if the last process ran successfully. |
int |
getReturnCode()
Returns the return code of the last process ran. |
java.lang.String |
getStderr()
Returns the stderr of the process last ran. |
java.lang.String |
getStdout()
Returns the stdout of the process last ran. |
void |
run()
Runs the current external process. |
void |
setCommandLine(java.lang.String[] commandLine)
Sets the command line of the process to run. |
void |
setDirectory(java.io.File dir)
Sets the directory to run the process in. |
void |
setEnvironmentVars(java.util.Map<java.lang.String,java.lang.String> vars,
boolean append)
Sets the environment variables to be set for this process. |
void |
setOutputListener(ProcessRunnerOutputListener listener)
Sets the output listener to receive notification when stdout or stderr is written to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProcessRunner(java.lang.String[] commandLine)
commandLine
- The command line to run, with each item in the
array being a single parameter.
java.lang.IllegalArgumentException
- If commandLine
has
length 0
.
java.lang.NullPointerException
- If commandLine
is
null
.Method Detail |
---|
public boolean getAppendEnvironmentVars()
getEnvironmentVars()
,
setEnvironmentVars(Map, boolean)
public java.lang.String getCommandLineString()
setCommandLine(String[])
public java.io.File getDirectory()
null
, then the process will run in the same
directory as this Java process.setDirectory(File)
public java.util.Map<java.lang.String,java.lang.String> getEnvironmentVars()
getAppendEnvironmentVars()
,
setEnvironmentVars(Map, boolean)
public java.lang.Throwable getLastError()
null
if the last process ran successfully.
public int getReturnCode()
public java.lang.String getStderr()
public java.lang.String getStdout()
public void run()
run
in interface java.lang.Runnable
java.io.IOException
- If an I/O error occurs while running the process.getStdout()
,
getStderr()
public void setDirectory(java.io.File dir)
dir
- The directory.getDirectory()
public void setCommandLine(java.lang.String[] commandLine) throws java.lang.IllegalArgumentException
commandLine
- The command line parameters to run.
java.lang.IllegalArgumentException
- If commandLine
has
length 0
.
java.lang.NullPointerException
- If commandLine
is
null
.getCommandLineString()
public void setEnvironmentVars(java.util.Map<java.lang.String,java.lang.String> vars, boolean append)
vars
- The environment variables. This may be null
if
none are to be set.append
- Whether this should be appended to the parent process's
environment. If this is false
, then the contents of
vars
will be the only environment variables set.getEnvironmentVars()
public void setOutputListener(ProcessRunnerOutputListener listener)
ProcessRunner
.
listener
- The new listener. The previous listener, if any,
will be removed. If this is null
, there
will be no output listener.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |