Package com.nimbusds.jose.util
Class BoundedInputStream
java.lang.Object
java.io.InputStream
com.nimbusds.jose.util.BoundedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Size-bounded input stream. Adapted from Apache Commons IO. Throws an
IOException if the input size limit is exceeded.- Version:
- 2016-11-28
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new unbounded input stream.BoundedInputStream(InputStream in, long size) Creates a new bounded input stream. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()longReturns the maximum number of bytes to return.booleanIndicates whether theclose()method should propagate to the underling InputStream.voidmark(int readlimit) booleanintread()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) toString()Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
BoundedInputStream
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
Creates a new unbounded input stream.- Parameters:
in- The input stream to wrap.
-
-
Method Details
-
getLimitBytes
Returns the maximum number of bytes to return.- Returns:
- The maximum number of bytes to return, -1 if no limit.
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
toString
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
mark
- Overrides:
markin classInputStream
-
markSupported
- Overrides:
markSupportedin classInputStream
-
isPropagateClose
Indicates whether theclose()method should propagate to the underling InputStream. -
setPropagateClose
Set whether theclose()method should propagate to the underling InputStream.
-