public class ReadInto extends Thread
InputStream and either accumulates the read bytes
in a String or outputs to a PrintStream.
Its intended use is to catch the output and error streams of Process
instances.
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected StringBuilder |
buffer |
protected boolean |
closeOnEOF |
protected boolean |
done |
protected PrintStream |
out |
protected BufferedReader |
reader |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
ReadInto(InputStream in,
PrintStream out)
Construct a ReadInto thread and start it right away.
|
ReadInto(InputStream in,
PrintStream out,
boolean closeOnEOF)
Construct a ReadInto thread and start it right away.
|
| Modifier and Type | Method and Description |
|---|---|
void |
done() |
void |
interrupt() |
void |
run()
The main method.
|
String |
toString()
Return the output as a
String unless a PrintStream was
specified in the constructor. |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yieldprotected BufferedReader reader
protected PrintStream out
protected StringBuilder buffer
protected boolean done
protected boolean closeOnEOF
public ReadInto(InputStream in, PrintStream out)
in - the stream to readout - the stream to print to; if it is null, the toString()
method will have the output insteadpublic ReadInto(InputStream in, PrintStream out, boolean closeOnEOF)
in - the stream to readout - the stream to print to; if it is null, the toString()
method will have the output insteadpublic void run()
It runs until interrupted, or until the InputStream ends, whichever
comes first.
public void done()
throws IOException
IOExceptionpublic String toString()
String unless a PrintStream was
specified in the constructor.Copyright © 2015–2022 SciJava. All rights reserved.