public class StreamGobbler
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private StreamGobblerCallback |
mCallback
The callback to be used.
|
private java.io.InputStream |
mIPStream
The input stream that is to be read from.
|
private LogManager |
mLogger
The handle to the logging object.
|
private java.io.OutputStream |
mOPStream
The output stream to which the contents have to be redirected to.
|
private java.lang.String |
mPrompt
The prompt that is to be written to the output stream.
|
private boolean |
mStarted
A boolean indicating whether the thread has started or not.
|
Constructor and Description |
---|
StreamGobbler(java.io.InputStream is,
StreamGobblerCallback callback)
The overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underneath input and output stream that were opened.
|
protected void |
finalize()
Closes the open connections to the streams whenever this object
is destroyed.
|
void |
redirect(java.io.OutputStream ops,
java.lang.String prompt)
Sets the output stream to which to redirect the contents of the input
stream.
|
void |
run()
The main method of the gobbler, that does all the work.
|
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 java.io.InputStream mIPStream
private java.io.OutputStream mOPStream
private StreamGobblerCallback mCallback
private java.lang.String mPrompt
private boolean mStarted
private LogManager mLogger
public StreamGobbler(java.io.InputStream is, StreamGobblerCallback callback)
is
- the input stream from which to read from.callback
- the callback to call when a line is read.public void redirect(java.io.OutputStream ops, java.lang.String prompt)
ops
- the output stream.prompt
- the prompt for the output stream.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void finalize()
finalize
in class java.lang.Object
public void close()