Closeable
, AutoCloseable
public class BoundedInputStream extends InputStream
BoundedInputStream
decorates an InputStream
and restricts
reading bytes from the InputStream
decoratee up to a given total
number of bytes (bounds). In case the total number of bytes readable has been
exceeded then an according IOException
is thrown.Constructor | Description |
---|---|
BoundedInputStream(InputStream aInputStream,
int aTotalBytes) |
Constructs a
BoundedInputStream instances by decorating the given
InputStream with the constraint of the given total number of
bytes (bounds) which can be read. |
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
|
void |
close() |
|
int |
getBytesAvaialable() |
Returns the total number of bytes to which this
InputStream is
bounded. |
int |
getBytesRead() |
Returns the number of bytes already been read by this stream.
|
int |
getTotalBytes() |
The total number of bytes (bounds) which can be read from this
InputStream . |
void |
mark(int readlimit) |
|
boolean |
markSupported() |
|
int |
read() |
|
int |
read(byte[] b) |
|
int |
read(byte[] b,
int off,
int len) |
|
byte[] |
readAllBytes() |
|
int |
readNBytes(byte[] arg0,
int arg1,
int arg2) |
|
void |
reset() |
|
long |
skip(long n) |
|
long |
transferTo(OutputStream out) |
public BoundedInputStream(InputStream aInputStream, int aTotalBytes)
BoundedInputStream
instances by decorating the given
InputStream
with the constraint of the given total number of
bytes (bounds) which can be read.aInputStream
- The InputStream
to be decorated.aTotalBytes
- The total number of bytes (bounds) available for
reading.public int read() throws IOException
read
in class InputStream
IOException
- if an I/O error occurs or the total number of bytes
readable would be exceeded (has already been consumed).public int getTotalBytes()
InputStream
.public int getBytesRead()
public int getBytesAvaialable()
InputStream
is
bounded.public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
close
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public boolean markSupported()
markSupported
in class InputStream
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public byte[] readAllBytes() throws IOException
readAllBytes
in class InputStream
IOException
public int readNBytes(byte[] arg0, int arg1, int arg2) throws IOException
readNBytes
in class InputStream
IOException
public void reset() throws IOException
reset
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public long transferTo(OutputStream out) throws IOException
transferTo
in class InputStream
IOException
Copyright © 2021. All rights reserved.