| |
|
| java.lang.Object java.io.InputStream com.Ostermiller.util.SizeLimitInputStream
SizeLimitInputStream | public class SizeLimitInputStream extends InputStream (Code) | | An input stream wrapper that will read only a set number of bytes from the
underlying stream.
author: Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities since: ostermillerutils 1.04.00 |
Field Summary | |
protected long | bytesRead The number of bytes that have been read
from this stream. | protected long | bytesReadSinceMark The number of bytes that have been read
from this stream since mark() was called. | protected InputStream | in The input stream that is being protected. | protected long | markReadLimitBytes The number of bytes the user has request
to have been marked for reset. | protected long | maxBytesToRead The number of bytes to read at most from this
Stream. |
Constructor Summary | |
public | SizeLimitInputStream(InputStream in, long maxBytesToRead) Create a new size limit input stream from
another stream given a size limit. |
Method Summary | |
public boolean | allBytesRead() Tell whether the number of bytes specified
in the constructor have been read yet. | public int | available() | public void | close() Close this stream and underlying streams. | public long | getBytesLeft() Get the maximum number of bytes left to read
before the limit (set in the constructor) is reached. | public long | getBytesRead() Get the number of bytes actually read
from this stream. | public long | getMaxBytesToRead() Get the number of total bytes (including bytes already read)
that can be read from this stream (as set in the constructor). | public void | mark(int readlimit) | public boolean | markSupported() | public int | read() | public int | read(byte[] b) | public int | read(byte[] b, int off, int len) | public void | reset() | public long | skip(long n) |
bytesRead | protected long bytesRead(Code) | | The number of bytes that have been read
from this stream. Read methods should
check to ensure that bytesRead never
exceeds maxBytesToRead.
since: ostermillerutils 1.04.00 |
bytesReadSinceMark | protected long bytesReadSinceMark(Code) | | The number of bytes that have been read
from this stream since mark() was called.
since: ostermillerutils 1.04.00 |
in | protected InputStream in(Code) | | The input stream that is being protected.
All methods should be forwarded to it,
after checking the size that has been read.
since: ostermillerutils 1.04.00 |
markReadLimitBytes | protected long markReadLimitBytes(Code) | | The number of bytes the user has request
to have been marked for reset.
since: ostermillerutils 1.04.00 |
maxBytesToRead | protected long maxBytesToRead(Code) | | The number of bytes to read at most from this
Stream. Read methods should
check to ensure that bytesRead never
exceeds maxBytesToRead.
since: ostermillerutils 1.04.00 |
SizeLimitInputStream | public SizeLimitInputStream(InputStream in, long maxBytesToRead)(Code) | | Create a new size limit input stream from
another stream given a size limit.
Parameters: in - The input stream. Parameters: maxBytesToRead - the max number of bytes to allow to be read from the underlying stream. since: ostermillerutils 1.04.00 |
allBytesRead | public boolean allBytesRead()(Code) | | Tell whether the number of bytes specified
in the constructor have been read yet.
true iff the specified number of bytes have all been read. since: ostermillerutils 1.04.00 |
close | public void close() throws IOException(Code) | | Close this stream and underlying streams.
Calling this method may make data on the
underlying stream unavailable.
Consider wrapping this stream in a NoCloseStream
so that clients can
call close() with no effect.
since: ostermillerutils 1.04.00 |
getBytesLeft | public long getBytesLeft()(Code) | | Get the maximum number of bytes left to read
before the limit (set in the constructor) is reached.
The number of bytes that (at a maximum) are left to be taken from this stream. since: ostermillerutils 1.04.00 |
getBytesRead | public long getBytesRead()(Code) | | Get the number of bytes actually read
from this stream.
number of bytes that have already been taken from this stream. since: ostermillerutils 1.04.00 |
getMaxBytesToRead | public long getMaxBytesToRead()(Code) | | Get the number of total bytes (including bytes already read)
that can be read from this stream (as set in the constructor).
Maximum bytes that can be read until the size limit runs out since: ostermillerutils 1.04.00 |
mark | public void mark(int readlimit)(Code) | | |
markSupported | public boolean markSupported()(Code) | | |
|
|
|