public class CommandRunner
extends java.lang.Thread
| Modifier and Type | Class and Description |
|---|---|
protected class |
CommandRunner.StreamGobbler
Constantly reads an input stream and captures its content.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String[] |
m_command |
protected int |
m_errorCode |
protected CommandRunner.StreamGobbler |
m_stderrGobbler |
protected java.lang.String |
m_stdin |
protected CommandRunner.StreamGobbler |
m_stdoutGobbler |
protected boolean |
m_stop |
| Constructor and Description |
|---|
CommandRunner(java.util.List<java.lang.String> command,
java.lang.String stdin)
Creates a CommandRunner to run a command.
|
CommandRunner(java.lang.String[] command)
Creates a CommandRunner to run a command.
|
CommandRunner(java.lang.String[] command,
java.lang.String stdin)
Creates a CommandRunner to run a command.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes()
Gets the contents of stdout sent by the command as an array of bytes
|
int |
getErrorCode()
Gets the return code of the command.
|
java.lang.String |
getString()
Gets the contents of stdout sent by the command as a string
|
void |
run() |
static byte[] |
runAndGet(java.lang.String[] command,
java.lang.String inputs) |
static byte[] |
runAndGet(java.lang.String command,
java.lang.String inputs) |
void |
stopCommand()
Interrupts the execution of the command
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected java.lang.String[] m_command
protected java.lang.String m_stdin
protected volatile boolean m_stop
protected CommandRunner.StreamGobbler m_stdoutGobbler
protected CommandRunner.StreamGobbler m_stderrGobbler
protected int m_errorCode
public CommandRunner(java.util.List<java.lang.String> command,
java.lang.String stdin)
command - The command to runstdin - If not set to null, this string will be sent to the stdin
of the command being runpublic CommandRunner(java.lang.String[] command,
java.lang.String stdin)
command - The command to runstdin - If not set to null, this string will be sent to the stdin
of the command being runpublic CommandRunner(java.lang.String[] command)
command - The command to runpublic static byte[] runAndGet(java.lang.String[] command,
java.lang.String inputs)
public static byte[] runAndGet(java.lang.String command,
java.lang.String inputs)
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic byte[] getBytes()
public java.lang.String getString()
public int getErrorCode()
public void stopCommand()
Copyright © Sylvain HallĂ©. All Rights Reserved.