public class InputStreamSink
extends java.lang.Object
implements java.lang.Runnable
It is especially useful for handling the outputting streams of Process
.
Create via startOn(InputStream)
which will automatically discard all
bytes from the stream in a background thread.
See also InputStreamBuffer
which collects the output in a ring buffer,
and InputStreamPipe
which forwards all bytes from one stream to another.
Constructor and Description |
---|
InputStreamSink(java.io.InputStream is)
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 InputStreamSink |
startOn(java.io.InputStream inStream)
Start a sink on the given stream.
|
public InputStreamSink(@NotNull java.io.InputStream is)
startOn(InputStream)
is
a better way to create an input stream sink.is
- input streampublic 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.Runnable
Thread.run()
@NotNull public static InputStreamSink startOn(@NotNull java.io.InputStream inStream)
inStream
- input stream