Package com.saperion.common.io
Class CountingInputStream
java.lang.Object
java.io.InputStream
com.saperion.common.io.CountingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
This
InputStream
counts the number of bytes read (or skipped) to determine the length of stream while
streaming.- Author:
- jschwarz
-
Constructor Summary
ConstructorsConstructorDescriptionCountingInputStream
(InputStream delegate) This constructor creates a new CountingInputStream that counts the bytes in the stream given. -
Method Summary
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
CountingInputStream
This constructor creates a new CountingInputStream that counts the bytes in the stream given.- Parameters:
delegate
- the InputStreams whose bytes are to count
-
-
Method Details
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
getNumberOfBytes
public long getNumberOfBytes()This method returns the number of bytes read from the stream so far.- Returns:
- the number of bytes read from the stream so far
-