Class PumpStreamHandler


  • public class PumpStreamHandler
    extends Object
    Copies standard output and error of children streams to standard output and error of the parent.
    • Method Detail

      • setChildOutputStream

        public void setChildOutputStream​(InputStream in)
        Set the input stream from which to read the standard output of the child.
        Parameters:
        in - the the child output stream.
      • setChildErrorStream

        public void setChildErrorStream​(InputStream in)
        Set the input stream from which to read the standard error of the child.
        Parameters:
        in - set the child error stream.
      • setChildInputStream

        public void setChildInputStream​(OutputStream out)
        Set the output stream by means of which input can be sent to the child.
        Parameters:
        out - set the child output stream.
      • attach

        public void attach​(Process p)
        Attach to a child streams from the given process.
        Parameters:
        p - The process to attach to.
      • start

        public void start()
        Start pumping the streams.
      • stop

        public void stop()
        Stop pumping the streams.
      • createChildOutputPump

        protected void createChildOutputPump​(InputStream in,
                                             OutputStream out)
        Create the pump to handle child output.
        Parameters:
        in - the child input stream.
        out - the child output stream.
      • createChildErrorPump

        protected void createChildErrorPump​(InputStream in,
                                            OutputStream out)
        Create the pump to handle error output.
        Parameters:
        in - the child input stream.
        out - the child output stream.
      • createPump

        protected StreamPumper createPump​(InputStream in,
                                          OutputStream out)
        Create a stream pumper to copy the given input stream to the given output stream.
        Parameters:
        in - the child input stream.
        out - the child output stream.
        Returns:
        A thread object that does the pumping.
      • createPump

        protected StreamPumper createPump​(InputStream in,
                                          OutputStream out,
                                          boolean closeWhenExhausted)
        Create a stream pumper to copy the given input stream to the given output stream.
        Parameters:
        in - The input stream to copy from.
        out - The output stream to copy to.
        closeWhenExhausted - If true close the input stream.
        Returns:
        A thread object that does the pumping.
      • createInputPump

        protected StreamPumper createInputPump​(InputStream in,
                                               OutputStream out,
                                               boolean closeWhenExhausted)
        Create a stream pumper to copy the given input stream to the given output stream. Used for standard input.
        Parameters:
        in - The input stream to copy from.
        out - The output stream to copy to.
        closeWhenExhausted - If true close the input stream.
        Returns:
        A thread object that does the pumping.