2.17.2: 2011-06-17

net.sf.basedb.util
Class InputStreamCombiner

java.lang.Object
  extended by java.io.InputStream
      extended by net.sf.basedb.util.InputStreamCombiner
All Implemented Interfaces:
Closeable

public class InputStreamCombiner
extends InputStream

An input stream implementation that reads one or more input streams sequentially. When the end of the first stream has been reached, reading continues on the next one, and so on until all streams have been read. The underlying streams are automatically closed once they have been fully read.

Since:
2.16
Author:
Nicklas
Last modified
$Date: 2010-05-27 10:54:05 +0200 (Thu, 27 May 2010) $

Field Summary
private  InputStream[] in
           
private  int index
           
 
Constructor Summary
InputStreamCombiner(InputStream... in)
          Create a new stream combiner using the given streams to read from
 
Method Summary
 int available()
           
 void close()
          Closes all underlying streams.
private  void nextStream()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private final InputStream[] in

index

private int index
Constructor Detail

InputStreamCombiner

public InputStreamCombiner(InputStream... in)
Create a new stream combiner using the given streams to read from

Parameters:
in - The stream to read from, must be an array with at least one stream
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Closes all underlying streams.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

nextStream

private void nextStream()

2.17.2: 2011-06-17