Package com.forgerock.opendj.util
Class SizeLimitInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.forgerock.opendj.util.SizeLimitInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class SizeLimitInputStream extends InputStream
An implementation of input stream that enforces an read size limit.
-
-
Constructor Summary
Constructors Constructor Description SizeLimitInputStream(InputStream parentStream, int readLimit)Creates a new a new size limit input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()intgetBytesRead()Retrieves the number of bytes read from this stream.intgetSizeLimit()Retrieves the size limit of this stream.voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] b, int off, int len)voidreset()longskip(long n)-
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
SizeLimitInputStream
public SizeLimitInputStream(InputStream parentStream, int readLimit)
Creates a new a new size limit input stream.- Parameters:
parentStream- The parent stream.readLimit- The size limit.
-
-
Method Detail
-
available
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getBytesRead
public int getBytesRead()
Retrieves the number of bytes read from this stream.- Returns:
- The number of bytes read from this stream.
-
getSizeLimit
public int getSizeLimit()
Retrieves the size limit of this stream.- Returns:
- The size limit of this stream.
-
mark
public void mark(int readlimit)
- Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
reset
public void reset() throws IOException- Overrides:
resetin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
-