public class ExternalProcess
extends java.lang.Object
Constructor and Description |
---|
ExternalProcess()
Empty constructor for serialization
|
ExternalProcess(ExternalProcess orig)
Copy constructor
|
ExternalProcess(java.lang.String cmd)
Creates a new ExternalProcess with no command line arguments, default working folder, and the current
environment variables.
|
ExternalProcess(java.lang.String cmd,
java.util.List<java.lang.String> args)
Creates a new ExternalProcess with the default working folder and the current environment variables.
|
ExternalProcess(java.lang.String cmd,
java.util.List<java.lang.String> args,
java.util.Map<java.lang.String,java.lang.String> environment,
java.io.File workingFolder)
Creates a new ExternalProcess
|
Modifier and Type | Method and Description |
---|---|
void |
addArgument(java.lang.String arg)
Appends a command line argument to the end of the current list.
|
void |
addArgument(java.lang.String arg,
int index)
Adds a command line argument
|
void |
addEnvironmentVariable(java.lang.String key,
java.lang.String value)
Adds/overwrites an environment variable.
|
void |
delArgument(java.lang.String arg)
Removes a command line argument if it exists.
|
void |
delEnvironmentVariable(java.lang.String key)
Removes an environment variable if it exists.
|
java.util.List<java.lang.String> |
getArgs()
Returns the list of arguments, where the first element is the command to run i.e.
|
java.lang.String |
getCmd()
Gets the current command
|
java.util.Map<java.lang.String,java.lang.String> |
getEnv()
Returns the environment variable settings for the external process.
|
java.lang.Process |
getProcess()
Returns a handle to the external process
|
java.io.File |
getWorkingFolder()
Gets the current working folder for the external process.
|
void |
setArgs(java.util.List<java.lang.String> args)
Sets the command line arguments.
|
void |
setCmd(java.lang.String cmd)
Sets the command to execute.
|
void |
setEnv(java.util.Map<java.lang.String,java.lang.String> env)
Sets the environment for the external process.
|
void |
setWorkingFolder(java.io.File workingFolder)
Sets the working folder for the external process.
|
void |
start()
Starts the external process
|
public ExternalProcess()
public ExternalProcess(java.lang.String cmd, java.util.List<java.lang.String> args, java.util.Map<java.lang.String,java.lang.String> environment, java.io.File workingFolder)
cmd
- command to executeargs
- command line argumentsenvironment
- environment variablesworkingFolder
- working folderpublic ExternalProcess(java.lang.String cmd)
cmd
- commandpublic ExternalProcess(java.lang.String cmd, java.util.List<java.lang.String> args)
cmd
- commandargs
- command line argumentspublic ExternalProcess(ExternalProcess orig)
orig
- original ExternalProcess to copypublic void addEnvironmentVariable(java.lang.String key, java.lang.String value)
key
- environment variable namevalue
- environment variable valuepublic void delEnvironmentVariable(java.lang.String key)
key
- key to removepublic void addArgument(java.lang.String arg, int index)
arg
- argument to addindex
- position of the argumentpublic void addArgument(java.lang.String arg)
arg
- argument to appendpublic void delArgument(java.lang.String arg)
arg
- argument to removepublic void start() throws java.io.IOException
java.io.IOException
- if an error occursjava.lang.NullPointerException
- if the command or any argument was passed as nullpublic java.util.Map<java.lang.String,java.lang.String> getEnv()
public void setEnv(java.util.Map<java.lang.String,java.lang.String> env)
env
- new environmentpublic java.util.List<java.lang.String> getArgs()
public void setArgs(java.util.List<java.lang.String> args)
args
- argumentspublic void setWorkingFolder(java.io.File workingFolder)
workingFolder
- new working folderpublic java.io.File getWorkingFolder()
public java.lang.String getCmd()
public void setCmd(java.lang.String cmd)
cmd
- commandpublic java.lang.Process getProcess()