public class LimitedLengthInputStream extends FilterInputStream
in
Constructor and Description |
---|
LimitedLengthInputStream(InputStream in,
long offset,
long length) |
Modifier and Type | Method and Description |
---|---|
int |
read()
Reads a single byte from the filtered stream and returns it as an integer
in the range from 0 to 255.
|
int |
read(byte[] buffer)
Equivalent to
read(buffer, 0, buffer.length) . |
int |
read(byte[] buffer,
int offset,
int byteCount)
Reads at most
count bytes from this stream and stores them in the
byte array buffer starting at offset . |
available, close, mark, markSupported, reset, skip
public LimitedLengthInputStream(InputStream in, long offset, long length) throws IOException
in
- underlying stream to wrapoffset
- offset into stream where data startslength
- length of data at offsetIOException
- if an error occurred with the underlying streampublic int read() throws IOException
FilterInputStream
read
in class FilterInputStream
IOException
- if the stream is closed or another IOException occurs.public int read(byte[] buffer, int offset, int byteCount) throws IOException
FilterInputStream
count
bytes from this stream and stores them in the
byte array buffer
starting at offset
. Returns the number
of bytes actually read or -1 if no bytes have been read and the end of
this stream has been reached. This implementation reads bytes from the
filtered stream.read
in class FilterInputStream
buffer
- the byte array in which to store the bytes read.offset
- the initial position in buffer
to store the bytes
read from this stream.byteCount
- the maximum number of bytes to store in buffer
.IOException
- if this stream is closed or another I/O error occurs.public int read(byte[] buffer) throws IOException
InputStream
read(buffer, 0, buffer.length)
.read
in class InputStream
IOException