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:
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
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
read
- Specified by:
readin 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
-