Class PumpStreamHandler

  • All Implemented Interfaces:
    ExecuteStreamHandler

    public class PumpStreamHandler
    extends Object
    implements ExecuteStreamHandler
    Copies standard output and error of sub-processes to standard output and error of the parent process. If output or error stream are set to null, any feedback from that stream will be lost.
    • Constructor Detail

      • PumpStreamHandler

        public PumpStreamHandler()
        Construct a new PumpStreamHandler.
      • PumpStreamHandler

        public PumpStreamHandler​(OutputStream outAndErr)
        Construct a new PumpStreamHandler.
        Parameters:
        outAndErr - the output/error OutputStream.
      • PumpStreamHandler

        public PumpStreamHandler​(OutputStream out,
                                 OutputStream err)
        Construct a new PumpStreamHandler.
        Parameters:
        out - the output OutputStream.
        err - the error OutputStream.
      • PumpStreamHandler

        public PumpStreamHandler​(OutputStream out,
                                 OutputStream err,
                                 InputStream input)
        Construct a new PumpStreamHandler.
        Parameters:
        out - the output OutputStream.
        err - the error OutputStream.
        input - the input InputStream.
    • Method Detail

      • setStopTimeout

        public void setStopTimeout​(long timeout)
        Set maximum time to wait until output streams are exchausted when stop() was called.
        Parameters:
        timeout - timeout in milliseconds or zero to wait forever (default)
      • stop

        public void stop()
                  throws IOException
        Stop pumping the streams. When a timeout is specified it it is not guaranteed that the pumper threads are cleanly terminated.
        Specified by:
        stop in interface ExecuteStreamHandler
        Throws:
        IOException - thrown when an I/O exception occurs.