edu.rice.cs.util
Class StreamRedirectThread

java.lang.Object
  extended by java.lang.Thread
      extended by edu.rice.cs.util.StreamRedirectThread
All Implemented Interfaces:
Runnable

public class StreamRedirectThread
extends Thread

StreamRedirectThread is a thread which copies its input to its output and terminates when it completes.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamRedirectThread(String name, InputStream in, OutputStream out)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, boolean close)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, boolean close, boolean keepRunning)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, boolean close, ThreadGroup tg)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, boolean close, ThreadGroup tg, boolean keepRunning)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, ThreadGroup tg)
          Constructor
StreamRedirectThread(String name, InputStream in, OutputStream out, ThreadGroup tg, boolean keepRunning)
          Constructor
 
Method Summary
 void run()
          Copy.
 void setInputStream(InputStream in)
          Set a new input stream.
 void setStopFlag()
          Tell the thread to stop copying.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            boolean close)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
close - true if the streams should be closed after copying has ended

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            ThreadGroup tg)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
tg - thread group for this thread

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            boolean close,
                            ThreadGroup tg)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
close - true if the streams should be closed after copying has ended
tg - thread group for this thread

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            boolean close,
                            boolean keepRunning)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
close - true if the streams should be closed after copying has ended
keepRunning - true if the thread should keep running and not terminate when a stream ends

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            ThreadGroup tg,
                            boolean keepRunning)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
tg - thread group for this thread
keepRunning - true if the thread should keep running and not terminate when a stream ends

StreamRedirectThread

public StreamRedirectThread(String name,
                            InputStream in,
                            OutputStream out,
                            boolean close,
                            ThreadGroup tg,
                            boolean keepRunning)
Constructor

Parameters:
name - thread name
in - stream to copy from
out - stream to copy to
close - true if the streams should be closed after copying has ended
tg - thread group for this thread
keepRunning - true if the thread should keep running and not terminate when a stream ends
Method Detail

setInputStream

public void setInputStream(InputStream in)
Set a new input stream.

Parameters:
in - new input stream to read from

run

public void run()
Copy.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

setStopFlag

public void setStopFlag()
Tell the thread to stop copying.