Package com.helger.commons.io.stream
Class CountingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.helger.commons.io.stream.WrappedInputStream
-
- com.helger.commons.io.stream.CountingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class CountingInputStream extends WrappedInputStream
A wrapper around anInputStreamthat counts the number of read bytes.- Author:
- Philip Helger
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description CountingInputStream(InputStream aSourceIS)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetBytesRead()longgetMark()longgetPosition()voidmark(int nReadlimit)intread()intread(byte[] aBuf, int nOffset, int nLength)voidreset()longskip(long n)StringtoString()-
Methods inherited from class com.helger.commons.io.stream.WrappedInputStream
getWrappedInputStream
-
Methods inherited from class java.io.FilterInputStream
available, close, markSupported, read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
CountingInputStream
public CountingInputStream(@Nonnull InputStream aSourceIS)
-
-
Method Detail
-
read
public int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] aBuf, int nOffset, int nLength) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
public long skip(@Nonnegative long n) throws IOException
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
mark
public void mark(@Nonnegative int nReadlimit)
- Overrides:
markin classFilterInputStream
-
reset
public void reset() throws IOException- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
getBytesRead
@Nonnegative public final long getBytesRead()
- Returns:
- The number of read bytes.
-
getPosition
@Nonnegative public final long getPosition()
- Returns:
- The current position in the input stream (taking skip and mark/reset into account)
-
getMark
@Nonnegative public final long getMark()
- Returns:
- The current mark
- Since:
- 9.3.8
-
toString
public String toString()
- Overrides:
toStringin classWrappedInputStream
-
-