public class InputStreamPipe
extends java.lang.Object
implements java.lang.Runnable
It is especially useful for handling the outputting streams of Process.
Create via startOn(InputStream, OutputStream) which will automatically
forward all bytes from the input stream to the output stream in a background thread.
See also InputStreamBuffer which collects the output in a ring buffer,
or InputStreamSink which discards all bytes read.
| Constructor and Description |
|---|
InputStreamPipe(java.io.InputStream is,
java.io.OutputStream os)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.IOException |
getError()
Return a possible error which happened during reading the stream
when using the
run() method. |
long |
getTotalByteCount()
Get the total number of bytes read by this sink.
|
void |
run()
When an object implementing interface
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
static InputStreamPipe |
startOn(java.io.InputStream inStream,
java.io.OutputStream outStream)
Start a pipe on the given stream.
|
public long getTotalByteCount()
@Nullable public java.io.IOException getError()
run() method.null,
if no error was caughtpublic void run()
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread.
The general contract of the method run is that it may
take any action whatsoever.
run in interface java.lang.RunnableThread.run()@NotNull public static InputStreamPipe startOn(@NotNull java.io.InputStream inStream, @NotNull java.io.OutputStream outStream)
inStream - input streamoutStream - output stream