Class CountingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.deltava.dao.http.CountingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An InputStream that counts the number of bytes read from it.
- Since:
- 10.3
- Version:
- 10.3
- Author:
- Luke
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionCountingInputStream
(InputStream in, IntConsumer onClose) Creates the InputStream. -
Method Summary
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
CountingInputStream
CountingInputStream(InputStream in, IntConsumer onClose) Creates the InputStream.- Parameters:
in
- the InputStream to wraponClose
- statistics update hook, called on close()
-
-
Method Details
-
getCount
public int getCount()Returns the number of bytes read from this stream.- Returns:
- the number of bytes
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-