Methods Summary |
---|
StreamPumper | createInputPump(java.io.InputStream is, java.io.OutputStream os, boolean closeWhenExhausted)Creates a stream pumper to copy the given input stream to the
given output stream. Used for standard input.
StreamPumper pumper = new StreamPumper(is, os, closeWhenExhausted);
pumper.setAutoflush(true);
return pumper;
|
protected void | createProcessErrorPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle error output.
errorThread = createPump(is, os);
|
protected void | createProcessOutputPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle process output.
outputThread = createPump(is, os);
|
protected java.lang.Thread | createPump(java.io.InputStream is, java.io.OutputStream os)Creates a stream pumper to copy the given input stream to the
given output stream.
return createPump(is, os, false);
|
protected java.lang.Thread | createPump(java.io.InputStream is, java.io.OutputStream os, boolean closeWhenExhausted)Creates a stream pumper to copy the given input stream to the
given output stream.
final Thread result
= new Thread(new StreamPumper(is, os, closeWhenExhausted));
result.setDaemon(true);
return result;
|
protected java.io.OutputStream | getErr()Get the error stream.
return err;
|
protected java.io.OutputStream | getOut()Get the output stream.
return out;
|
public void | setProcessErrorStream(java.io.InputStream is)Set the InputStream from which to read the
standard error of the process.
if (err != null) {
createProcessErrorPump(is, err);
}
|
public void | setProcessInputStream(java.io.OutputStream os)Set the OutputStream by means of which
input can be sent to the process.
if (input != null) {
inputPump = createInputPump(input, os, true);
} else {
try {
os.close();
} catch (IOException e) {
//ignore
}
}
|
public void | setProcessOutputStream(java.io.InputStream is)Set the InputStream from which to read the
standard output of the process.
createProcessOutputPump(is, out);
|
public void | start()Start the Thread s.
outputThread.start();
errorThread.start();
if (inputPump != null) {
Thread inputThread = new Thread(inputPump);
inputThread.setDaemon(true);
inputThread.start();
}
|
public void | stop()Stop pumping the streams.
try {
outputThread.join();
} catch (InterruptedException e) {
// ignore
}
try {
errorThread.join();
} catch (InterruptedException e) {
// ignore
}
if (inputPump != null) {
inputPump.stop();
}
try {
err.flush();
} catch (IOException e) {
// ignore
}
try {
out.flush();
} catch (IOException e) {
// ignore
}
|