public class PumpStreamHandler extends Object implements ExecuteStreamHandler
| Modifier and Type | Field and Description |
|---|---|
protected OutputStream |
err |
protected Thread |
errorThread |
protected InputStream |
input |
protected InputStreamPumper |
inputStreamPumper |
protected Thread |
inputThread |
protected OutputStream |
out |
protected Thread |
outputThread |
| Constructor and Description |
|---|
PumpStreamHandler()
Construct a new
PumpStreamHandler. |
PumpStreamHandler(OutputStream outAndErr)
Construct a new
PumpStreamHandler. |
PumpStreamHandler(OutputStream out,
OutputStream err)
Construct a new
PumpStreamHandler. |
PumpStreamHandler(OutputStream out,
OutputStream err,
InputStream input)
Construct a new
PumpStreamHandler. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createProcessErrorPump(InputStream is,
OutputStream os)
Create the pump to handle error output.
|
protected void |
createProcessOutputPump(InputStream is,
OutputStream os)
Create the pump to handle process output.
|
protected Thread |
createPump(InputStream is,
OutputStream os)
Creates a stream pumper to copy the given input stream to the given
output stream.
|
protected Thread |
createPump(InputStream is,
OutputStream os,
boolean closeWhenExhausted)
Creates a stream pumper to copy the given input stream to the given
output stream.
|
protected Thread |
createPump(InputStream is,
OutputStream os,
boolean closeWhenExhausted,
boolean flushImmediately)
Creates a stream pumper to copy the given input stream to the given
output stream.
|
protected Thread |
createSystemInPump(InputStream is,
OutputStream os)
Creates a stream pumper to copy the given input stream to the given
output stream.
|
void |
flush() |
OutputStream |
getErr()
Get the error stream.
|
InputStream |
getInput()
Get the input stream.
|
OutputStream |
getOut()
Get the output stream.
|
protected Thread |
newThread(Runnable task)
Override this to customize how the background task is created.
|
void |
setProcessErrorStream(InputStream is)
Set the
InputStream from which to read the standard error
of the process. |
void |
setProcessInputStream(OutputStream os)
Set the
OutputStream by means of which input can be sent
to the process. |
void |
setProcessOutputStream(InputStream is)
Set the
InputStream from which to read the standard output
of the process. |
void |
start()
Start the
Threads. |
void |
stop()
Stop pumping the streams.
|
protected Runnable |
wrapTask(Runnable task)
Override this to customize how the background task is created.
|
protected Thread outputThread
protected Thread errorThread
protected Thread inputThread
protected final OutputStream out
protected final OutputStream err
protected final InputStream input
protected InputStreamPumper inputStreamPumper
public PumpStreamHandler()
PumpStreamHandler.public PumpStreamHandler(OutputStream outAndErr)
PumpStreamHandler.outAndErr - the output/error OutputStream.public PumpStreamHandler(OutputStream out, OutputStream err)
PumpStreamHandler.out - the output OutputStream.err - the error OutputStream.public PumpStreamHandler(OutputStream out, OutputStream err, InputStream input)
PumpStreamHandler.out - the output OutputStream.err - the error OutputStream.input - the input InputStream.public void setProcessOutputStream(InputStream is)
InputStream from which to read the standard output
of the process.setProcessOutputStream in interface ExecuteStreamHandleris - the InputStream.public void setProcessErrorStream(InputStream is)
InputStream from which to read the standard error
of the process.setProcessErrorStream in interface ExecuteStreamHandleris - the InputStream.public void setProcessInputStream(OutputStream os)
OutputStream by means of which input can be sent
to the process.setProcessInputStream in interface ExecuteStreamHandleros - the OutputStream.public void start()
Threads.start in interface ExecuteStreamHandlerpublic void stop()
stop in interface ExecuteStreamHandlerpublic void flush()
public OutputStream getOut()
OutputStream.public OutputStream getErr()
OutputStream.public InputStream getInput()
InputStream.protected void createProcessOutputPump(InputStream is, OutputStream os)
is - the InputStream.os - the OutputStream.protected void createProcessErrorPump(InputStream is, OutputStream os)
is - the InputStream.os - the OutputStream.protected Thread createPump(InputStream is, OutputStream os)
is - the input stream to copy fromos - the output stream to copy intoprotected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted)
is - the input stream to copy fromos - the output stream to copy intocloseWhenExhausted - close the output stream when the input stream is exhaustedprotected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted, boolean flushImmediately)
is - the input stream to copy fromos - the output stream to copy intocloseWhenExhausted - close the output stream when the input stream is exhaustedflushImmediately - flush the output stream whenever data was written to itprotected Thread createSystemInPump(InputStream is, OutputStream os)
is - the System.in input stream to copy fromos - the output stream to copy intoprotected Thread newThread(Runnable task)
task - the task to be run in the backgroundCopyright © 2020 ZeroTurnaround. All rights reserved.