public class UnionInputStream
extends java.io.InputStream
This stream may enter into an EOF state, returning -1 from any of the read methods, and then later successfully read additional bytes if a new InputStream is added after reaching EOF.
Currently this stream does not support the mark/reset APIs. If mark and later
reset functionality is needed the caller should wrap this stream with a
BufferedInputStream
.
Constructor and Description |
---|
UnionInputStream()
Create an empty InputStream that is currently at EOF state.
|
UnionInputStream(java.io.InputStream... inputStreams)
Create an InputStream that is a union of the individual streams.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.io.InputStream in)
Add the given InputStream onto the end of the stream queue.
|
int |
available() |
void |
close() |
boolean |
isEmpty()
Returns true if there are no more InputStreams in the stream queue.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
long |
skip(long len) |
public UnionInputStream()
public UnionInputStream(java.io.InputStream... inputStreams)
As each stream reaches EOF, it will be automatically closed before bytes from the next stream are read.
inputStreams
- streams to be pushed onto this stream.public void add(java.io.InputStream in)
When the stream reaches EOF it will be automatically closed.
in
- the stream to add; must not be null.public boolean isEmpty()
If this method returns true
then all read methods will signal EOF
by returning -1, until another InputStream has been pushed into the queue
with add(InputStream)
.
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public long skip(long len) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
Copyright © 2012. All Rights Reserved.