Package com.nimbusds.jose.util
Class BoundedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.nimbusds.jose.util.BoundedInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class BoundedInputStream extends java.io.InputStreamSize-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(java.io.InputStream in)Creates a new unbounded input stream.BoundedInputStream(java.io.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)java.lang.StringtoString()
-
-
-
Constructor Detail
-
BoundedInputStream
public BoundedInputStream(java.io.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(java.io.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 java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
isPropagateClose
public boolean isPropagateClose()
Indicates whether theclose()method should propagate to the underling InputStream.
-
-