Package org.ka2ddo.yaac.io
Class CountingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.ka2ddo.yaac.io.CountingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
InputStream to count the number of bytes read from the input, so as to drive
a progress bar.
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorDescriptionCreate a CountingInputStream wrapped around the specified InputStream. -
Method Summary
Modifier and TypeMethodDescriptionfinal long
Get the number of bytes passed through this stream (so far).void
mark
(int readlimit) Override mark to do nothing.boolean
Override the markSupported operation.final int
read()
Read a byte.final int
read
(byte[] b) Read an array of bytes.final int
read
(byte[] b, int off, int len) Read bytes into an offset array.void
reset()
Override reset to reset the byte count.final long
skip
(long n) Skip some bytes.Methods inherited from class java.io.FilterInputStream
available, close
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
CountingInputStream
Create a CountingInputStream wrapped around the specified InputStream.- Parameters:
in
- the InputStream to count.
-
-
Method Details
-
markSupported
public boolean markSupported()Override the markSupported operation.- Overrides:
markSupported
in classFilterInputStream
-
mark
public void mark(int readlimit) Override mark to do nothing.- Overrides:
mark
in classFilterInputStream
-
reset
public void reset()Override reset to reset the byte count.- Overrides:
reset
in classFilterInputStream
-
read
Read a byte.- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
Read an array of bytes.- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
Read bytes into an offset array.- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
Skip some bytes.- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
getByteCount
public final long getByteCount()Get the number of bytes passed through this stream (so far).- Returns:
- the number of read bytes so far.
-