Package org.apache.commons.exec
Class PumpStreamHandler
java.lang.Object
org.apache.commons.exec.PumpStreamHandler
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionConstruct a newPumpStreamHandler.PumpStreamHandler(OutputStream outAndErr) Construct a newPumpStreamHandler.PumpStreamHandler(OutputStream out, OutputStream err) Construct a newPumpStreamHandler.PumpStreamHandler(OutputStream out, OutputStream err, InputStream input) Construct a newPumpStreamHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoidSet theInputStreamfrom which to read the standard error of the process.voidSet theOutputStreamby means of which input can be sent to the process.voidSet theInputStreamfrom which to read the standard output of the process.voidsetStopTimeout(long timeout) Set maximum time to wait until output streams are exchausted whenstop()was called.voidstart()Start theThreads.voidstop()Stop pumping the streams.
-
Constructor Details
-
PumpStreamHandler
public PumpStreamHandler()Construct a newPumpStreamHandler. -
PumpStreamHandler
Construct a newPumpStreamHandler.- Parameters:
outAndErr- the output/errorOutputStream.
-
PumpStreamHandler
Construct a newPumpStreamHandler.- Parameters:
out- the outputOutputStream.err- the errorOutputStream.
-
PumpStreamHandler
Construct a newPumpStreamHandler.- Parameters:
out- the outputOutputStream.err- the errorOutputStream.input- the inputInputStream.
-
-
Method Details
-
setStopTimeout
public void setStopTimeout(long timeout) Set maximum time to wait until output streams are exchausted whenstop()was called.- Parameters:
timeout- timeout in milliseconds or zero to wait forever (default)
-
setProcessOutputStream
Set theInputStreamfrom which to read the standard output of the process.- Specified by:
setProcessOutputStreamin interfaceExecuteStreamHandler- Parameters:
is- theInputStream.
-
setProcessErrorStream
Set theInputStreamfrom which to read the standard error of the process.- Specified by:
setProcessErrorStreamin interfaceExecuteStreamHandler- Parameters:
is- theInputStream.
-
setProcessInputStream
Set theOutputStreamby means of which input can be sent to the process.- Specified by:
setProcessInputStreamin interfaceExecuteStreamHandler- Parameters:
os- theOutputStream.
-
start
public void start()Start theThreads.- Specified by:
startin interfaceExecuteStreamHandler
-
stop
Stop pumping the streams. When a timeout is specified it it is not guaranteed that the pumper threads are cleanly terminated.- Specified by:
stopin interfaceExecuteStreamHandler- Throws:
IOException- thrown when an I/O exception occurs.
-