public class ContinuousInputStream
extends java.io.FilterInputStream
InputStream wrapper that reads from a queue of underlying InputStreams, giving the impression that all data is coming from a single,
continuous, source.| Modifier and Type | Field and Description |
|---|---|
private boolean |
closed |
private java.util.Queue<java.io.InputStream> |
inputStreams |
| Modifier | Constructor and Description |
|---|---|
protected |
ContinuousInputStream(java.io.InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
addInputStream(java.io.InputStream newIn)
Adds another
InputStream to the InputStreams queue. |
int |
available()
Returns the number of bytes available in the active underlying
InputStream. |
void |
close()
Closes this stream and all underlying
InputStreams. |
private void |
ensureOpen()
Ensures that this
InputStream wasn't closed yet. |
private boolean |
nextInLine()
Closes the currently active
InputStream and replaces it by the the head of the InputStreams queue. |
int |
read()
Reads one byte from the underlying
InputStream. |
int |
read(byte[] b)
Forwards the read to
read(byte[], int, int). |
int |
read(byte[] b,
int off,
int len)
Reads bytes from the underlying
InputStream. |
private java.util.Queue<java.io.InputStream> inputStreams
private boolean closed
public int available()
throws java.io.IOException
InputStream.available in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.available()public void close()
throws java.io.IOException
InputStreams.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.close()public int read()
throws java.io.IOException
InputStream. When EOF is reached, then reads from the next InputStream in the queue.read in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.read()public int read(byte[] b)
throws java.io.IOException
read(byte[], int, int).read in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.read(byte[])public int read(byte[] b,
int off,
int len)
throws java.io.IOException
InputStream. When EOF is reached, then reads from the next InputStream in the queue.read in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.read(byte[], int, int)protected boolean addInputStream(java.io.InputStream newIn)
InputStream to the InputStreams queue.newIn - the InputStream to add.true if the element was added to the InputStreams queue.private boolean nextInLine()
throws java.io.IOException
InputStream and replaces it by the the head of the InputStreams queue.true if the currently active InputStream was replaced by a new one.java.io.IOException - if errors occur while closing the currently active InputStream.private void ensureOpen()
throws java.io.IOException
InputStream wasn't closed yet.java.io.IOException - if this InputStream was closed.