public class StringReader extends Object implements LineReader
LineReader designed to stream lines of text to one or more
delegate LineReaders. It also stores all input so that a new LineReader can be added
at any time, and it will still receive all text that was streamed to this reader.
This is handy for such use cases as forwarding an external processes std in and std out, where we might need to add a listener to the process after it has already started.
This class has also been enhanced with the waitToEnd() method,
which will block until the line producer (such as a thread streaming input from an external process)
has signalled that the stream is finished by calling onEnd().
| Constructor and Description |
|---|
StringReader() |
| Modifier and Type | Method and Description |
|---|---|
void |
forwardTo(LineReader callback) |
void |
onEnd() |
protected void |
onEnd0() |
void |
onLine(String line) |
void |
onStart() |
String |
toString() |
void |
waitToEnd() |
void |
waitToEnd(long timeout,
int nanos) |
public void onStart()
onStart in interface LineReaderpublic void onLine(String line)
onLine in interface LineReaderpublic final void onEnd()
onEnd in interface LineReaderprotected void onEnd0()
public void forwardTo(LineReader callback)
public void waitToEnd()
throws InterruptedException
InterruptedExceptionpublic void waitToEnd(long timeout,
int nanos)
throws InterruptedException
InterruptedExceptionCopyright © December 07, 2012–2015 The Internet Party. All rights reserved.