Package gw.util
Class ShellProcess
java.lang.Object
gw.util.ShellProcess
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoiddestroy()Kills the subprocess.intReturns the exit value for the subprocess.booleanReturns true if the process is done, false if notreadChar()readLine()Reads a line of text from stdout.Reads a line of text from stderr.readStderrUntil(char character, boolean includeDeliminator) Reads a group of text from stderr.private StringreadStreamUntil(InputStream stream, boolean includeDelim, char... character) Reads a group of text from stdout.intwaitFor()Causes the current thread to wait, if necessary, until the process represented by thisProcessobject has terminated.voidWrites the specified text to stdin
-
Field Details
-
_javaProcess
-
_stdin
-
-
Constructor Details
-
ShellProcess
ShellProcess(Process javaProcess)
-
-
Method Details
-
readLine
Reads a line of text from stdout. This method will block until a newline(\n) character has been received. This method is equivilent to calling readUntil('\n', false)<\i>- Returns:
- The line of text that was read
-
readUntil
Reads a group of text from stdout. The line will start from the previous point until the read character. This method will block until the specified character is read.- Parameters:
character- the character to read untilincludeDeliminator- true to include the deliminator in the returned text, false to not.- Returns:
- The text that was read
-
readChar
-
readStderrLine
Reads a line of text from stderr. This method will block until a newline(\n) character has been received. This method is equivilent to calling readUntil('\n', false)<\i>- Returns:
- The line of text that was read
-
readStderrUntil
Reads a group of text from stderr. The line will start from the previous point until the read character. This method will block until the specified character is read.- Parameters:
character- the character to read untilincludeDeliminator- true to include the deliminator in the returned text, false to not.- Returns:
- The text that was read
-
write
Writes the specified text to stdin- Parameters:
text- the text to write
-
closeStdout
public void closeStdout() -
closeStderr
public void closeStderr() -
closeStdin
public void closeStdin() -
waitFor
Causes the current thread to wait, if necessary, until the process represented by thisProcessobject has terminated. This method returns immediately if the subprocess has already terminated. If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits.- Returns:
- the exit value of the process. By convention,
0indicates normal termination. - Throws:
InterruptedException- if the current thread isinterruptedby another thread while it is waiting, then the wait is ended and anInterruptedExceptionis thrown.
-
exitValue
public int exitValue()Returns the exit value for the subprocess.- Returns:
- the exit value of the subprocess represented by this
Processobject. by convention, the value0indicates normal termination. - Throws:
IllegalThreadStateException- if the subprocess represented by thisProcessobject has not yet terminated.
-
getIsDone
public boolean getIsDone()Returns true if the process is done, false if not -
destroy
public void destroy()Kills the subprocess. The subprocess represented by thisProcessobject is forcibly terminated. -
readStreamUntil
-