Class PumpStreamHandler

  • All Implemented Interfaces:
    ExecuteStreamHandler

    public class PumpStreamHandler
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      PumpStreamHandler()
      Construct a new PumpStreamHandler.
      PumpStreamHandler​(java.io.OutputStream outAndErr)
      Construct a new PumpStreamHandler.
      PumpStreamHandler​(java.io.OutputStream out, java.io.OutputStream err)
      Construct a new PumpStreamHandler.
      PumpStreamHandler​(java.io.OutputStream out, java.io.OutputStream err, java.io.InputStream input)
      Construct a new PumpStreamHandler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void setProcessErrorStream​(java.io.InputStream is)
      Set the InputStream from which to read the standard error of the process.
      void setProcessInputStream​(java.io.OutputStream os)
      Set the OutputStream by means of which input can be sent to the process.
      void setProcessOutputStream​(java.io.InputStream is)
      Set the InputStream from which to read the standard output of the process.
      void setStopTimeout​(long timeout)
      Set maximum time to wait until output streams are exchausted when stop() was called.
      void start()
      Start the Threads.
      void stop()
      Stop pumping the streams.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PumpStreamHandler

        public PumpStreamHandler()
        Construct a new PumpStreamHandler.
      • PumpStreamHandler

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

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

        public PumpStreamHandler​(java.io.OutputStream out,
                                 java.io.OutputStream err,
                                 java.io.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)
      • setProcessOutputStream

        public void setProcessOutputStream​(java.io.InputStream is)
        Set the InputStream from which to read the standard output of the process.
        Specified by:
        setProcessOutputStream in interface ExecuteStreamHandler
        Parameters:
        is - the InputStream.
      • setProcessErrorStream

        public void setProcessErrorStream​(java.io.InputStream is)
        Set the InputStream from which to read the standard error of the process.
        Specified by:
        setProcessErrorStream in interface ExecuteStreamHandler
        Parameters:
        is - the InputStream.
      • setProcessInputStream

        public void setProcessInputStream​(java.io.OutputStream os)
        Set the OutputStream by means of which input can be sent to the process.
        Specified by:
        setProcessInputStream in interface ExecuteStreamHandler
        Parameters:
        os - the OutputStream.
      • stop

        public void stop()
                  throws java.io.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:
        java.io.IOException - thrown when an I/O exception occurs.