public class SequenceInputStream extends InputStream
InputStreams. Reads are taken from the first stream until it ends, then the next stream is used, until the last stream returns end of file.
|Constructor and Description|
Constructs a new SequenceInputStream using the elements returned from
Constructs a new
|Modifier and Type||Method and Description|
Closes all streams in this sequence of input stream.
Reads a single byte from this sequence of input streams and returns it as an integer in the range from 0 to 255.
Reads at most
copyTo, copyToByteArray, finalize, read, readFully, readFully
public SequenceInputStream(InputStream s1, InputStream s2)
SequenceInputStreamusing the two streams
s2as the sequence of streams to read from.
s1- the first stream to get bytes from.
s2- the second stream to get bytes from.
public void close()
public int read()
public int read(byte buffer, int offset, int count)
countbytes from this sequence of input streams and stores them in the byte array
offset. Blocks only until at least 1 byte has been read, the end of the stream has been reached, or an exception is thrown.
This SequenceInputStream shows the same behavior as other
InputStreams. To do this it will read only as many bytes as a call to read on the current substream returns. If
that call does not return as many bytes as requested by
count, it will not retry to read more on its own
because subsequent reads might block. This would violate the rule that it will only block until at least one byte
has been read.
If a substream has already reached the end when this call is made, it will close that substream and start with the next one. If there are no more substreams it will return -1.
buffer- the array in which to store the bytes read.
offset- the initial position in
bufferto store the bytes read from this stream.
count- the maximum number of bytes to store in
offset < 0or
count < 0, or if
offset + countis greater than the size of