Package com.nimbusds.jose.util
Class BoundedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.nimbusds.jose.util.BoundedInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class BoundedInputStream extends InputStream
Size-bounded input stream. Adapted from Apache Commons IO. Throws anIOExceptionif the input size limit is exceeded.- Version:
- 2016-11-28
-
-
Constructor Summary
Constructors Constructor Description BoundedInputStream(InputStream in)Creates a new unbounded input stream.BoundedInputStream(InputStream in, long size)Creates a new bounded input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()longgetLimitBytes()Returns the maximum number of bytes to return.booleanisPropagateClose()Indicates whether theclose()method should propagate to the underling InputStream.voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()voidsetPropagateClose(boolean propagateClose)Set whether theclose()method should propagate to the underling InputStream.longskip(long n)StringtoString()-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
BoundedInputStream
public BoundedInputStream(InputStream in, long size)
Creates a new bounded input stream.- Parameters:
in- The input stream to wrap.size- The maximum number of bytes to return, -1 if no limit.
-
BoundedInputStream
public BoundedInputStream(InputStream in)
Creates a new unbounded input stream.- Parameters:
in- The input stream to wrap.
-
-
Method Detail
-
getLimitBytes
public long getLimitBytes()
Returns the maximum number of bytes to return.- Returns:
- The maximum number of bytes to return, -1 if no limit.
-
read
public int read() throws IOException
- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skipin classInputStream- Throws:
IOException
-
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
-
reset
public void reset() throws IOException
- Overrides:
resetin classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream
-
isPropagateClose
public boolean isPropagateClose()
Indicates whether theclose()method should propagate to the underling InputStream.
-
setPropagateClose
public void setPropagateClose(boolean propagateClose)
Set whether theclose()method should propagate to the underling InputStream.
-
-