public class ConcatInputStream
extends java.io.InputStream
| Constructor and Description | 
|---|
ConcatInputStream()
Create a new input stream that can dynamically accept new sources. 
 | 
ConcatInputStream(java.io.InputStream in)
Create a new InputStream with one source. 
 | 
ConcatInputStream(java.io.InputStream[] in)
Create a new InputStream with an arbitrary number of sources. 
 | 
ConcatInputStream(java.io.InputStream in1,
                 java.io.InputStream in2)
Create a new InputStream with two sources. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addInputStream(java.io.InputStream in)
Add the given inputStream to the queue of inputStreams from which to
 concatenate data. 
 | 
void | 
addInputStreams(java.io.InputStream[] in)
Add the given inputStream to the queue of inputStreams from which to
 concatenate data. 
 | 
int | 
available()
Returns the number of bytes that can be read (or skipped over) from this input
 stream without blocking by the next caller of a method for this input stream. 
 | 
void | 
close()
Closes this input stream and releases any system resources associated with the stream. 
 | 
void | 
lastInputStreamAdded()
Causes the addInputStream method to throw IllegalStateException
 and read() methods to return -1 (end of stream)
 when there is no more available data. 
 | 
void | 
mark(int readlimit)
Mark not supported 
 | 
boolean | 
markSupported()
Does not support mark. 
 | 
int | 
read()
Reads the next byte of data from the underlying streams. 
 | 
int | 
read(byte[] b)
Reads some number of bytes from the underlying streams and stores them into
 the buffer array b. 
 | 
int | 
read(byte[] b,
    int off,
    int len)
Reads up to length bytes of data from the underlying streams into an array of bytes. 
 | 
void | 
reset()
Reset not supported. 
 | 
long | 
skip(long n)
Skips over and discards n bytes of data from this input stream. 
 | 
public ConcatInputStream()
New sources should be added using the addInputStream() method. When all sources have been added the lastInputStreamAdded() should be called so that read methods can return -1 (end of stream).
Adding new sources may by interleaved with read calls.
public ConcatInputStream(java.io.InputStream in)
in - InputStream to use as a source.java.lang.NullPointerException - if in is nullpublic ConcatInputStream(java.io.InputStream in1,
                         java.io.InputStream in2)
in1 - first InputStream to use as a source.in2 - second InputStream to use as a source.java.lang.NullPointerException - if either source is null.public ConcatInputStream(java.io.InputStream[] in)
in - InputStreams to use as a sources.java.lang.NullPointerException - if the input array on any element is null.public void lastInputStreamAdded()
Calling this method when this class is no longer accepting more inputStreams has no effect.
public void addInputStream(java.io.InputStream in)
in - InputStream to add to the concatenation.java.lang.IllegalStateException - if more inputStreams can't be added because lastInputStreamAdded() has been called, close() has been called, or a constructor with inputStream parameters was used.public void addInputStreams(java.io.InputStream[] in)
in - InputStream to add to the concatenation.java.lang.IllegalStateException - if more inputStreams can't be added because lastInputStreamAdded() has been called, close() has been called, or a constructor with inputStream parameters was used.java.lang.NullPointerException - the array of inputStreams, or any of the contents is null.public int read()
         throws java.io.IOException
If this class in not done accepting inputstreams and the end of the last known stream is reached, this method will block forever unless another thread adds an inputstream or interrupts.
read in class java.io.InputStreamjava.io.IOException - if an I/O error occurs.public int read(byte[] b)
         throws java.io.IOException
If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte.
 The read(b) method for class InputStream has the same effect as:
 read(b, 0, b.length)
 
If this class in not done accepting inputstreams and the end of the last known stream is reached, this method will block forever unless another thread adds an inputstream or interrupts.
read in class java.io.InputStreamb - - Destination bufferjava.io.IOException - - If an I/O error occursjava.lang.NullPointerException - - If b is null.public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
If length is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte.
This method blocks until input data is available
If this class in not done accepting inputstreams and the end of the last known stream is reached, this method will block forever unless another thread adds an inputstream or interrupts.
read in class java.io.InputStreamb - Destination bufferoff - Offset at which to start storing byteslen - Maximum number of bytes to readjava.io.IOException - - If an I/O error occursjava.lang.NullPointerException - - If b is null.java.lang.IndexOutOfBoundsException - - if length or offset are not possible.public long skip(long n)
          throws java.io.IOException
If this class in not done accepting inputstreams and the end of the last known stream is reached, this method will block forever unless another thread adds an inputstream or interrupts.
skip in class java.io.InputStreamn - he number of characters to skipjava.io.IOException - If an I/O error occurspublic int available()
              throws java.io.IOException
available in class java.io.InputStreamjava.io.IOException - If an I/O error occurspublic void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readlimit)
mark in class java.io.InputStreampublic void reset()
           throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOException - because reset is not supported.public boolean markSupported()
markSupported in class java.io.InputStreamCopyright (c) 2001-2020 by Stephen Ostermiller