public class PumpStreamHandler extends Object implements ExecuteStreamHandler
Modifier and Type | Class and Description |
---|---|
protected static class |
PumpStreamHandler.ThreadWithPumper
Specialized subclass that allows access to the running StreamPumper.
|
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 . |
PumpStreamHandler(OutputStream out,
OutputStream err,
InputStream input,
boolean nonBlockingRead)
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 nonBlockingIO)
Creates a stream pumper to copy the given input stream to the
given output stream.
|
protected void |
finish(Thread t)
Waits for a thread to finish while trying to make it finish
quicker by stopping the pumper (if the thread is a
ThreadWithPumper instance) or interrupting
the thread. |
protected OutputStream |
getErr()
Get the error stream.
|
protected OutputStream |
getOut()
Get the output stream.
|
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
Thread s. |
void |
stop()
Stop pumping the streams.
|
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 PumpStreamHandler(OutputStream out, OutputStream err, InputStream input, boolean nonBlockingRead)
PumpStreamHandler
.out
- the output OutputStream
.err
- the error OutputStream
.input
- the input InputStream
.nonBlockingRead
- set it to true
if the input should be
read with simulated non blocking IO.protected void createProcessErrorPump(InputStream is, OutputStream os)
is
- the input stream to copy from.os
- the output stream to copy to.protected void createProcessOutputPump(InputStream is, OutputStream os)
is
- the InputStream
.os
- the OutputStream
.protected Thread createPump(InputStream is, OutputStream os)
is
- the input stream to copy from.os
- the output stream to copy to.protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted)
is
- the input stream to copy from.os
- the output stream to copy to.closeWhenExhausted
- if true close the inputstream.ThreadWithPumper
.protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted, boolean nonBlockingIO)
is
- the input stream to copy from.os
- the output stream to copy to.closeWhenExhausted
- if true close the inputstream.nonBlockingIO
- set it to true
to use simulated non
blocking IO.ThreadWithPumper
.protected final void finish(Thread t)
ThreadWithPumper
instance) or interrupting
the thread.protected OutputStream getErr()
OutputStream
.protected OutputStream getOut()
OutputStream
.public void setProcessErrorStream(InputStream is)
InputStream
from which to read the
standard error of the process.setProcessErrorStream
in interface ExecuteStreamHandler
is
- the InputStream
.public void setProcessInputStream(OutputStream os)
OutputStream
by means of which
input can be sent to the process.setProcessInputStream
in interface ExecuteStreamHandler
os
- the OutputStream
.public void setProcessOutputStream(InputStream is)
InputStream
from which to read the
standard output of the process.setProcessOutputStream
in interface ExecuteStreamHandler
is
- the InputStream
.public void start()
Thread
s.start
in interface ExecuteStreamHandler
public void stop()
stop
in interface ExecuteStreamHandler