org.ka2ddo.yaac.io
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.ka2ddo.yaac.io.CountingInputStream
All Implemented Interfaces:
java.io.Closeable

public final class CountingInputStream
extends java.io.FilterInputStream

InputStream to count the number of bytes read from the input, so as to drive a progress bar.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CountingInputStream(java.io.InputStream in)
          Create a CountingInputStream wrapped around the specified InputStream.
 
Method Summary
 long getByteCount()
          Get the number of bytes passed through this stream (so far).
 void mark(int readlimit)
          Override mark to do nothing.
 boolean markSupported()
          Override the markSupported operation.
 int read()
          Read a byte.
 int read(byte[] b)
          Read an array of bytes.
 int read(byte[] b, int off, int len)
          Read bytes into an offset array.
 void reset()
          Override reset to reset the byte count.
 long skip(long n)
          Skip some bytes.
 
Methods inherited from class java.io.FilterInputStream
available, close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountingInputStream

public CountingInputStream(java.io.InputStream in)
Create a CountingInputStream wrapped around the specified InputStream.

Parameters:
in - the InputStream to count.
Method Detail

markSupported

public boolean markSupported()
Override the markSupported operation.

Overrides:
markSupported in class java.io.FilterInputStream

mark

public void mark(int readlimit)
Override mark to do nothing.

Overrides:
mark in class java.io.FilterInputStream

reset

public void reset()
           throws java.io.IOException
Override reset to reset the byte count.

Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public final int read()
               throws java.io.IOException
Read a byte.

Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public final int read(byte[] b)
               throws java.io.IOException
Read an array of bytes.

Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public final int read(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Read bytes into an offset array.

Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

skip

public final long skip(long n)
                throws java.io.IOException
Skip some bytes.

Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.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.