Package org.apache.wayang.core.util
Class LimitedInputStream
java.lang.Object
java.io.InputStream
org.apache.wayang.core.util.LimitedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStream that is trimmed to a specified size. Moreover, it counts the number of read bytes.-
Constructor Summary
ConstructorsConstructorDescriptionLimitedInputStream(InputStream wrappedInputStream) Create an unlimited instance.LimitedInputStream(InputStream wrappedInputStream, long maxReadBytes) Create a limited instance. -
Method Summary
Methods inherited from class java.io.InputStream
mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
LimitedInputStream
Create an unlimited instance.- Parameters:
wrappedInputStream-InputStreamthat is to be wrapped by this instance
-
LimitedInputStream
Create a limited instance.- Parameters:
wrappedInputStream-InputStreamthat is to be wrapped by this instancemaxReadBytes- maximum number of bytes to read from the stream
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
getNumReadBytes
public long getNumReadBytes()- Returns:
- the number of bytes that have been read from this stream
-