|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.biojava.utils.ProcessTools
public class ProcessTools
Convenience methods for running external processes. This class
offers wrappers around the java.lang.Process API,
but hides away the details of managing threads and process I/O.
StringWriter out = new StringWriter();
ProcessTools.exec(
new String[] {"/usr/bin/wc", "-w"},
"The quick brown fox jumps over the lazy dog",
out,
null
);
int numWords = Integer.parseInt(out.toString().trim());
| Method Summary | |
|---|---|
static int |
exec(String[] args,
Reader input,
Writer stdout,
Writer stderr)
Deprecated. Execute the specified command and wait for it to return. |
static int |
exec(String[] args,
String[] envp,
File dir,
Reader input,
Writer stdout,
Writer stderr,
long timeout)
Deprecated. Execute the specified command and wait for it to return, or kill it if the specified timeout expires first. |
static int |
exec(String command,
Reader input,
Writer stdout,
Writer stderr)
Deprecated. Execute the specified command and wait for it to return. |
static int |
exec(String command,
String[] envp,
File dir,
Reader input,
Writer stdout,
Writer stderr,
long timeout)
Deprecated. Execute the specified command and wait for it to return. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int exec(String[] args,
Reader input,
Writer stdout,
Writer stderr)
throws IOException
args - the command line to execute.input - data to present to the process' standard input, or null if the process does not require input.stdout - a Writer which will be filled with data from the process' output stream, or null to ignore output.stderr - a Writer which will be filled with data from the process' error stream, or null to ignore output.
IOException
public static int exec(String[] args,
String[] envp,
File dir,
Reader input,
Writer stdout,
Writer stderr,
long timeout)
throws IOException,
ProcessTimeoutException
args - the command line to execute.envp - environment variables for the child process, or null to inherit the current set.dir - working directory for the child process, or null to inherit the current directory.input - data to present to the process' standard input, or null if the process does not require input.stdout - a Writer which will be filled with data from the process' output stream, or null to ignore output.stderr - a Writer which will be filled with data from the process' error stream, or null to ignore output.timeout - maximum run-time (in milliseconds) for the child process. A value of 0 indicates no limit.
IOException - if an error occurs while starting or communicating with the process
ProcessTimeoutException - if the child process was killed because its timeout had expired.
public static int exec(String command,
Reader input,
Writer stdout,
Writer stderr)
throws IOException
command - the command line to execute.input - data to present to the process' standard input, or
null if the process does not require input.stdout - a Writer which will be filled with data
from the process' output stream, or null to ignore output.stderr - a Writer which will be filled with data
from the process' error stream, or null to ignore output.
IOException - if an error occurs while starting or communicating
with the process
public static int exec(String command,
String[] envp,
File dir,
Reader input,
Writer stdout,
Writer stderr,
long timeout)
throws IOException,
ProcessTimeoutException
command - the command line to execute.input - data to present to the process' standard input, or
null if the process does not require input.stdout - a Writer which will be filled with data
from the process' output stream, or null to ignore output.stderr - a Writer which will be filled with data
from the process' error stream, or null to ignore output.timeout - maximum run-time (in milliseconds) for the child process. A value of 0 indicates no limit.
IOException - if an error occurs while starting or communicating
with the process
ProcessTimeoutException - if the child process was killed because its timeout had expired.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||