public class NestedReader
extends java.io.Reader
insert(Reader) and insert(Reader,NestedReader.EOFListener) methods and are consumed
completely before returning to read from the previous stream. Note
that inserted streams are automatically closed after having being
consumed. Further note that closing a nested reader closes all
streams currently associated with that nested reader.| Modifier and Type | Class and Description |
|---|---|
static interface |
NestedReader.EOFListener
Event listener to provide notification a stream has reached its
end.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
Flag for whether this nested reader has been closed.
|
protected NestedReader.EOFListener |
listener
The corresponding end-of-file listener.
|
protected java.util.LinkedList<NestedReader.EOFListener> |
listenerStack
The stack of listeners, with the most recently added listener at
the front.
|
protected java.io.Reader |
reader
The current character stream.
|
protected java.util.LinkedList<java.io.Reader> |
readerStack
The stack of readers, with the most recently added stream at the
front.
|
| Constructor and Description |
|---|
NestedReader(java.io.Reader in)
Create a new nested reader.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
insert(java.io.Reader in)
Insert the specified character stream.
|
void |
insert(java.io.Reader in,
NestedReader.EOFListener eof)
Insert the specified character stream.
|
java.io.Reader |
open(java.lang.String file)
Open the specified file.
|
int |
read() |
int |
read(char[] cbuf,
int off,
int len) |
protected boolean closed
protected java.io.Reader reader
protected NestedReader.EOFListener listener
protected java.util.LinkedList<java.io.Reader> readerStack
protected java.util.LinkedList<NestedReader.EOFListener> listenerStack
public NestedReader(java.io.Reader in)
in - The main stream.public java.io.Reader open(java.lang.String file)
throws java.io.IOException
file - The file name.java.io.IOException - Signals an I/O error.public void insert(java.io.Reader in)
throws java.io.IOException
in - The stream.java.io.IOException - Signals an I/O error.public void insert(java.io.Reader in,
NestedReader.EOFListener eof)
throws java.io.IOException
notifies the
specified listener.in - The stream.eof - The listener to be notified when the specified stream
has been consumed.java.io.IOException - Signals an I/O error.public int read()
throws java.io.IOException
read in class java.io.Readerjava.io.IOExceptionpublic int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
read in class java.io.Readerjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Readerjava.io.IOExceptionCopyright © 2014. All Rights Reserved.