public class FixedSizeInputStream extends FilterInputStream
Modifier and Type | Field and Description |
---|---|
protected long |
maxsize
maximum bytes to read
|
protected long |
size
number of bytes read so far
|
protected boolean |
suppressClose
prevent a close() from doing anyhing, like closing the underlying stream
|
in
Constructor and Description |
---|
FixedSizeInputStream(InputStream in,
long _maxsize)
create a new FixedSizeInputStream, using in as the underlying
InputStream, and maxsize as the maximum number of bytes to read.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
read()
Read a single byte from the underlying Reader.
|
int |
read(byte[] cbuf,
int off,
int len)
Read bytes into a portion of an array.
|
void |
reset() |
long |
skip(long n)
Skips n bytes from the stream.
|
void |
suppressClose()
Sets it so that close() will never be called
|
available, read
protected final long maxsize
protected long size
protected boolean suppressClose
public FixedSizeInputStream(InputStream in, long _maxsize)
in
- underlying InputStream to read bytes from._maxsize
- maximum number of bytes to read.public int read() throws IOException
read
in class FilterInputStream
IOException
- If an I/O error occurs.public int read(byte[] cbuf, int off, int len) throws IOException
read
in class FilterInputStream
cbuf
- Destination bufferoff
- Offset at which to start storing byteslen
- Maximum number of bytes to readIOException
- If an I/O error occurs in the underlying reader.public long skip(long n) throws IOException
skip
in class FilterInputStream
n
- long the number of characters to skip.IOException
- if there is any error while
reading from the stream.public boolean markSupported()
markSupported
in class FilterInputStream
public void mark(int readAheadLimit)
mark
in class FilterInputStream
public void reset() throws IOException
reset
in class FilterInputStream
IOException
public void suppressClose()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
Terrier 4.0. Copyright © 2004-2014 University of Glasgow