org.scijava.util
Class ReadInto
java.lang.Object
java.lang.Thread
org.scijava.util.ReadInto
- All Implemented Interfaces:
- Runnable
public class ReadInto
- extends Thread
This class takes an 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.
- Author:
- Johannes Schindelin
Methods inherited from class java.lang.Thread |
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, yield |
reader
protected BufferedReader reader
out
protected PrintStream out
buffer
protected StringBuilder buffer
done
protected boolean done
closeOnEOF
protected boolean closeOnEOF
ReadInto
public ReadInto(InputStream in,
PrintStream out)
- Construct a ReadInto thread and start it right away.
- Parameters:
in
- the stream to readout
- the stream to print to; if it is null, the toString()
method will have the output instead
ReadInto
public ReadInto(InputStream in,
PrintStream out,
boolean closeOnEOF)
- Construct a ReadInto thread and start it right away.
- Parameters:
in
- the stream to readout
- the stream to print to; if it is null, the toString()
method will have the output instead
run
public void run()
- The main method.
It runs until interrupted, or until the InputStream
ends, whichever
comes first.
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
interrupt
public void interrupt()
- Overrides:
interrupt
in class Thread
done
public void done()
throws IOException
- Throws:
IOException
toString
public String toString()
- Return the output as a
String
unless a PrintStream
was
specified in the constructor.
- Overrides:
toString
in class Thread
Copyright © 2009–2014 SciJava. All rights reserved.