org.jagatoo.util.streams
Class RestrictedLengthInputStream
java.lang.Object
java.io.InputStream
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.
|
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 |
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 fromlength - The number of bytes to allow access to
- Throws:
java.io.IOException
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