Package oms3.util
Class Processes
- java.lang.Object
-
- oms3.util.Processes
-
public class Processes extends Object
ProcessExcecution. Helper class to execute external programs.- Author:
- od
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>environment()get the execution environment.intexec()Process execution.static voidmain(String[] args)voidredirectError(Writer w)Redirect the error streamvoidredirectOutput(Writer w)Redirect the output streamvoidsetArguments(Object... args)Set the execution arguments.voidsetLog(Logger log)voidsetWorkingDirectory(File dir)Set the working directory where the process get executed.
-
-
-
Constructor Detail
-
Processes
public Processes(File executable)
Create a new ProcessExecution.- Parameters:
executable- the executable file.
-
-
Method Detail
-
setLog
public void setLog(Logger log)
-
setArguments
public void setArguments(Object... args)
Set the execution arguments.- Parameters:
args- the command line arguments
-
setWorkingDirectory
public void setWorkingDirectory(File dir)
Set the working directory where the process get executed.- Parameters:
dir- the directory in which the executable will be started
-
environment
public Map<String,String> environment()
get the execution environment. Use the returned map to customize the environment variables.- Returns:
- the process environment.
-
exec
public int exec() throws IOExceptionProcess execution. This call blocks until the process is done.- Returns:
- the exit status of the process.
- Throws:
ExceptionIOException
-
redirectOutput
public void redirectOutput(Writer w)
Redirect the output stream- Parameters:
w- the stream handler
-
redirectError
public void redirectError(Writer w)
Redirect the error stream- Parameters:
w- the new handler.
-
-