com.google.enterprise.adaptor.prebuilt
Class Command

java.lang.Object
  extended by com.google.enterprise.adaptor.prebuilt.Command

public class Command
extends Object

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

exec

public static Command.Result exec(String[] command)
                           throws IOException,
                                  InterruptedException
Same as exec(command, null, new byte[0]).

Throws:
IOException
InterruptedException

exec

public static Command.Result exec(String[] command,
                                  File workingDir)
                           throws IOException,
                                  InterruptedException
Same as exec(command, workingDir, new byte[0]).

Throws:
IOException
InterruptedException
See Also:
exec(String[], File, byte[])

exec

public static Command.Result exec(String[] command,
                                  byte[] stdin)
                           throws IOException,
                                  InterruptedException
Same as exec(command, null, stdin).

Throws:
IOException
InterruptedException
See Also:
exec(String[], File, byte[])

exec

public static Command.Result exec(String[] command,
                                  File workingDir,
                                  byte[] stdin)
                           throws IOException,
                                  InterruptedException
Create process 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.

Throws:
IOException - if creating process fails
InterruptedException