|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.enterprise.adaptor.prebuilt.Command
public class Command
Exec helper that allows easy handling of stdin, stdout, and stderr. Normally
you have to worry about deadlock when dealing with those streams (as
mentioned briefly in Process
), so this class handles that for you.
Nested Class Summary | |
---|---|
static class |
Command.Result
Result data from an invocation |
Method Summary | |
---|---|
static Command.Result |
exec(String[] command)
Same as exec(command, null, new byte[0]) . |
static Command.Result |
exec(String[] command,
byte[] stdin)
Same as exec(command, null, stdin) . |
static Command.Result |
exec(String[] command,
File workingDir)
Same as exec(command, workingDir, new byte[0]) . |
static Command.Result |
exec(String[] command,
File workingDir,
byte[] stdin)
Create process command starting in the workingDir and
providing stdin as input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Command.Result exec(String[] command) throws IOException, InterruptedException
exec(command, null, new byte[0])
.
IOException
InterruptedException
public static Command.Result exec(String[] command, File workingDir) throws IOException, InterruptedException
exec(command, workingDir, new byte[0])
.
IOException
InterruptedException
exec(String[], File, byte[])
public static Command.Result exec(String[] command, byte[] stdin) throws IOException, InterruptedException
exec(command, null, stdin)
.
IOException
InterruptedException
exec(String[], File, byte[])
public static Command.Result exec(String[] command, File workingDir, byte[] stdin) throws IOException, InterruptedException
command
starting in the workingDir
and
providing stdin
as input. This method blocks until the process
exits. Stdout and stderr are available via Command.Result.getStdout()
and
Command.Result.getStderr()
. Before using them, however, you should generally
make sure that the process exited with a return code of zero, as other
return codes typically indicate an error.
IOException
- if creating process fails
InterruptedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |