|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dellroad.stuff.io.AsyncInputStream
public class AsyncInputStream
Performs asynchonous reads on an InputStream and notifies of input events.
Reads are performed in a dedicated background thread, from which the configured listener is notified. The background thread runs until this instance is closed, EOF or an exception is detected on the input, or a listener callback method throws an exception.
Instances of this class are thread-safe. The close() method may be safely invoked re-entrantly from the
listener callback methods.
| Nested Class Summary | |
|---|---|
static interface |
AsyncInputStream.Listener
Callback interface required by AsyncInputStream. |
| Field Summary | |
|---|---|
protected Logger |
log
|
| Constructor Summary | |
|---|---|
AsyncInputStream(InputStream input,
String name,
AsyncInputStream.Listener listener)
Constructor. |
|
| Method Summary | |
|---|---|
void |
close()
Close this instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Logger log
| Constructor Detail |
|---|
public AsyncInputStream(InputStream input,
String name,
AsyncInputStream.Listener listener)
If listener is null, this instance effectively reads and discards all of the input in a background thread.
input - underlying input streamname - name for this instance; used to create the name of the background threadlistener - callback object for input events, or null for none
IllegalArgumentException - if any parameter is null| Method Detail |
|---|
public void close()
Does nothing if already closed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||