|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.base.StreamRedirector
public class StreamRedirector
Class which reads from an input stream and pipes the data to a specified output stream.
All input is immediately flushed, as it is possible (although uncommon) for a subject to be designed to act on input without waiting for a newline. Note however that all streams are buffered, so if input occurs while this thread is not running it will be stored, and will be written as a block before being flushed when the thread runs again. If there is no input to be read, the thread will simply sleep.
The thread will terminate automatically if either the input stream or
output stream is closed, so it is not necessary to explicitly signal this
thread when the subject terminates. It can however be manually terminated
by calling the stop
method.
The primary intent of this class is to provide a means for redirecting input on stdin to a subject class. It is also used to prevent deadlock when a subject is not instrumented.
Constructor Summary | |
---|---|
StreamRedirector(java.io.InputStream source,
java.io.OutputStream sink,
boolean closeOutOnFinish,
java.io.PrintStream stderrStream)
Standard constructor, creates a buffered connection from the specified input stream to the specified output stream. |
Method Summary | |
---|---|
void |
run()
Pipes data from input stream to output stream. |
void |
stop()
Stops the thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamRedirector(java.io.InputStream source, java.io.OutputStream sink, boolean closeOutOnFinish, java.io.PrintStream stderrStream)
source
- Input stream from which data will be redirected to the
output stream.sink
- Output stream to which input stream data will be
redirected.closeOutOnFinish
- Specifies whether the output stream should be
closed if the end of the input stream is reached. This is true, for
example, when redirecting input to a subject.Method Detail |
---|
public void stop()
public void run()
stop
method is called.
run
in interface java.lang.Runnable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |