public final class OutputReader
extends java.lang.Thread
InputStream
and buffer this data. Once
end-of-stream is reached, this data will be made available as a String
.
Note that since the data is buffered in memory, so it is not advisable to use this OutputReader to read large amounts of data.Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
buffer |
private static int |
BUFFER_SIZE |
private boolean |
finished |
private java.io.InputStream |
source |
Constructor and Description |
---|
OutputReader(java.io.InputStream source)
Create an OutputReader that reads from
source . |
Modifier and Type | Method and Description |
---|---|
private void |
addToBuffer(byte[] bytes,
int length) |
java.lang.String |
getResult()
Returns the data that has been read from the
InputStream as a String . |
boolean |
isFinished()
Returns if the OutputReader has finished (i.e., has reached the end-of-stream on the input).
|
void |
run()
Entry method for daemon thread.
|
private void |
setFinished() |
void |
waitUntilFinished()
Waits until the OutputReader has finished (i.e., has reached the end-of-stream on the input).
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private static final int BUFFER_SIZE
private final java.io.InputStream source
private java.nio.ByteBuffer buffer
private boolean finished
public OutputReader(java.io.InputStream source)
source
.source
- the {#link InputStream} to read from.private void setFinished()
public boolean isFinished()
getResult()
.public void waitUntilFinished()
getResult()
.private void addToBuffer(byte[] bytes, int length)
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public java.lang.String getResult()
InputStream
as a String
. If the
OutputReader has not finished reading, this method will block until end-of-stream has been reached.