public class ProcessUtilFns
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
ProcessUtilFns() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Process |
exec(java.lang.String command)
Executes the specified string command in a separate process.
|
static java.lang.Process |
exec(java.lang.String[] commandArr,
java.io.PrintStream stderrPrintStream,
java.io.PrintStream stdoutPrintStream)
Executes the specified command and arguments in a separate process.
|
static java.lang.Process |
exec(java.lang.String command,
java.io.PrintStream stderrPrintStream,
java.io.PrintStream stdoutPrintStream)
Executes the specified string command in a separate process.
|
static java.lang.Integer |
exitValue(java.lang.Process p)
Returns the exit value for the specified process.
|
static java.lang.Integer |
waitFor(java.lang.Process p)
causes the current thread to wait, if necessary, until the
specified process has terminated.
|
static java.lang.Integer |
waitFor(java.lang.Process p,
long millis)
causes the current thread to wait, if necessary, until the
specified process has terminated.
|
public static java.lang.Process exec(java.lang.String command)
throws java.io.IOException
Warning: It is possible that the program will deadlock if the process generates enough output to overflow the system.
command - a specified system command.Process object for managing the process.java.lang.SecurityException - if a security manager exists and its
checkExec method doesn't allow creation of a process.java.io.IOException - if an I/O error occurs
The command argument is parsed into tokens and then
executed as a command in a separate process. The token parsing is
done by a {@link java.util.StringTokenizer} created by the call:
new StringTokenizer(command)
with no further modifications of the character categories.
This method has exactly the same effect as
exec(command, null).,
Runtime.exec(java.lang.String, java.lang.String[]),
SecurityManager.checkExec(java.lang.String)public static java.lang.Process exec(java.lang.String command,
java.io.PrintStream stderrPrintStream,
java.io.PrintStream stdoutPrintStream)
throws java.io.IOException
The command argument is parsed into tokens and then
executed as a command in a separate process. The token parsing is
done by a StringTokenizer created by the call:
with no further modifications of the character categories. This method has exactly the same effect asnew StringTokenizer(command)
exec(command, null).command - a specified system command.stderrPrintStream - "standard" error output print stream or
null if the "standard" error output is to be ignored.stdoutPrintStream - "standard" output print stream or
null if the "standard" output is to be ignored.Process object for managing the process.java.lang.SecurityException - if a security manager exists and its
checkExec method doesn't allow creation of a process.java.io.IOException - if an I/O error occursRuntime.exec(java.lang.String, java.lang.String[]),
SecurityManager.checkExec(java.lang.String)public static java.lang.Process exec(java.lang.String[] commandArr,
java.io.PrintStream stderrPrintStream,
java.io.PrintStream stdoutPrintStream)
throws java.io.IOException
commandArr is
executed as a command in a separate process.commandArr - array containing the command to call and
its arguments.stderrPrintStream - "standard" error output print stream or
null if the "standard" error output is to be ignored.stdoutPrintStream - "standard" output print stream or
null if the "standard" output is to be ignored.Process object for managing the process.java.lang.SecurityException - if a security manager exists and its
checkExec method doesn't allow creation of a process.java.io.IOException - if an I/O error occursRuntime.exec(java.lang.String, java.lang.String[]),
SecurityManager.checkExec(java.lang.String)public static java.lang.Integer exitValue(java.lang.Process p)
p - the process.Process object or
null if the process has not yet terminated.
By convention, 0 indicates normal termination.public static java.lang.Integer waitFor(java.lang.Process p)
throws java.lang.InterruptedException
p - the process.0 indicates normal termination.java.lang.InterruptedException - if the current thread is
interrupted by another thread
while it is waiting, then the wait is ended and an
InterruptedException is thrown.public static java.lang.Integer waitFor(java.lang.Process p,
long millis)
throws java.lang.InterruptedException
p - the process.millis - Waits at most millis milliseconds for this thread to exit.
A timeout of 0 means to wait forever.0 indicates normal termination.java.lang.InterruptedException - if the current thread is
interrupted by another thread
while it is waiting, then the wait is ended and an
InterruptedException is thrown.