org.yajul.io
Class ByteCountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.yajul.io.ByteCountingInputStream
All Implemented Interfaces:
java.io.Closeable

public class ByteCountingInputStream
extends java.io.FilterInputStream

InputStream class that counts the number of bytes read.

Author:
Josh

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ByteCountingInputStream(java.io.InputStream is)
           
 
Method Summary
 double getAverageThroughput()
          Returns the average throughput in bytes per second.
 int getByteCount()
          Returns the number of bytes read from the input stream.
 long getElapsedTime()
          Returns the elapsed time in milliseconds since the first byte was read, or since the resetStatistics() method was called.
 int read()
           
 int read(byte[] b, int off, int len)
           
 void resetStatistics()
          Reset the throughput statistics.
 long skip(long n)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteCountingInputStream

public ByteCountingInputStream(java.io.InputStream is)
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.IOException

getByteCount

public int getByteCount()
Returns the number of bytes read from the input stream.

Returns:
the number of bytes read from the input stream.

resetStatistics

public void resetStatistics()
Reset the throughput statistics.


getElapsedTime

public long getElapsedTime()
Returns the elapsed time in milliseconds since the first byte was read, or since the resetStatistics() method was called.

Returns:
the elapsed time in milliseconds since the first byte was read, or since the resetStatistics() method was called.

getAverageThroughput

public double getAverageThroughput()
Returns the average throughput in bytes per second.

Returns:
the average throughput in bytes per second.


Copyright © 2008. All Rights Reserved.