Package gw.util

Class ShellProcess


  • public class ShellProcess
    extends Object
    • Method Detail

      • readLine

        public String 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

        public String readUntil​(String character,
                                boolean includeDeliminator)
        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 until
        includeDeliminator - true to include the deliminator in the returned text, false to not.
        Returns:
        The text that was read
      • readChar

        public String readChar()
      • readStderrLine

        public String 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

        public String readStderrUntil​(char character,
                                      boolean includeDeliminator)
        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 until
        includeDeliminator - true to include the deliminator in the returned text, false to not.
        Returns:
        The text that was read
      • write

        public void write​(String text)
        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

        public int waitFor()
                    throws InterruptedException
        Causes the current thread to wait, if necessary, until the process represented by this Process object 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, 0 indicates normal termination.
        Throws:
        InterruptedException - if the current thread is interrupted by another thread while it is waiting, then the wait is ended and an InterruptedException is thrown.
      • exitValue

        public int exitValue()
        Returns the exit value for the subprocess.
        Returns:
        the exit value of the subprocess represented by this Process object. by convention, the value 0 indicates normal termination.
        Throws:
        IllegalThreadStateException - if the subprocess represented by this Process object 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 this Process object is forcibly terminated.