things.thinger.io
Class ChainedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by things.thinger.io.ChainedInputStream
All Implemented Interfaces:
java.io.Closeable

public class ChainedInputStream
extends java.io.InputStream

Chain up a set of input streams. This isn't the fastest thing in the world, so use judiciously. The chained streams will be read in turn. NONE WILL BE CLOSED.

Version:
1.0

Version History

EPG - Initial - 20 FEB 05
 
Author:
Erich P. Gatejen

Constructor Summary
ChainedInputStream(java.io.InputStream... streams)
          Constructor.
 
Method Summary
 int available()
          Returns the number of characters available for read without blocking.
 void close()
          Nop
 void mark(int readlimit)
          Mark does nothing.
 boolean markSupported()
          Mark does nothing so this will always return false.
 int read()
          Read a single character.
 void reset()
          Reset is not supported and will always throw and IOException.
 long skip(long n)
          Skip is not supported and will always throw an IOException.
 
Methods inherited from class java.io.InputStream
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainedInputStream

public ChainedInputStream(java.io.InputStream... streams)
                   throws java.lang.Exception
Constructor. This is a one-use echo.

Parameters:
streams - The input streams. Each one will be read in turn. Null elements will be ignored, but at least one has to be non-null. They will NOT BE CLOSED.
Throws:
java.lang.Exception
Method Detail

close

public void close()
           throws java.io.IOException
Nop

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

read

public int read()
         throws java.io.IOException
Read a single character. It will echo to the echo stream before returning.

Specified by:
read in class java.io.InputStream
Returns:
the character.
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Skip is not supported and will always throw an IOException.

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Returns the number of characters available for read without blocking. This is a bit tricky in that it'll count for the currently read stream only.

Overrides:
available in class java.io.InputStream
Returns:
the number available.
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Mark does nothing.

Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Reset is not supported and will always throw and IOException.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Mark does nothing so this will always return false.

Overrides:
markSupported in class java.io.InputStream
Returns:
false


Things.