org.jagatoo.util.streams
Class RestrictedLengthInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.jagatoo.util.streams.RestrictedLengthInputStream
All Implemented Interfaces:
java.io.Closeable

public class RestrictedLengthInputStream
extends java.io.InputStream

An Input Stream, that allows access only to a defined number of bytes.


Constructor Summary
RestrictedLengthInputStream(java.io.InputStream in, int length)
          Construct a new input stream
 
Method Summary
 int available()
          Check how many bytes are available on this stream
 int read()
          Read a single byte from the stream
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestrictedLengthInputStream

public RestrictedLengthInputStream(java.io.InputStream in,
                                   int length)
                            throws java.io.IOException
Construct a new input stream

Parameters:
in - The input stream to read from
length - The number of bytes to allow access to
Throws:
java.io.IOException
Method Detail

read

public int read()
         throws java.io.IOException
Read a single byte from the stream

Specified by:
read in class java.io.InputStream
Returns:
The byte read
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Check how many bytes are available on this stream

Overrides:
available in class java.io.InputStream
Returns:
The number of bytes available on this stream
Throws:
java.io.IOException