public class MultiReader
extends java.io.FilterReader
When instantiated, there may be no connection to any reader. If the
read()
method is called while in this state, a -1
is
returned signalling the EOF
condition.
Once the switchTo(java.io.Reader)
method is called, read()
delegates the work to the read()
method of the current
underlying reader.
This class may be useful in many situations. For instance,
PushbackReader
can provide pushback functionality for multiple
underlying readers once in an efficient way.
Constructor and Description |
---|
MultiReader()
Default constructor.
|
MultiReader(java.io.Reader reader)
Creates an instance with the specified associated reader as the
current reader.
|
Modifier and Type | Method and Description |
---|---|
int |
read()
Reads the next byte from the current stream.
|
void |
switchTo(java.io.Reader reader)
Switches input to the specified reader.
|
public MultiReader()
public MultiReader(java.io.Reader reader)
reader
- The reader that should be used first.public void switchTo(java.io.Reader reader)
reader
- The reader to be switched to.public int read() throws java.io.IOException
-1
as the indication of the
EOF
condition.read
in class java.io.FilterReader
java.io.IOException
- If any error occurs in reading from the underlying reader.