org.apache.commons.io.input
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.apache.commons.io.input.ProxyInputStream
              extended by org.apache.commons.io.input.CountingInputStream
All Implemented Interfaces:
Closeable

public class CountingInputStream
extends ProxyInputStream

Used in debugging, it counts the number of bytes that pass through it.

Version:
$Id: CountingInputStream.java 140517 2004-02-23 04:40:29Z bayard $
Author:
Henri Yandell

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CountingInputStream(InputStream in)
          Constructs a new CountingInputStream.
 
Method Summary
 int getCount()
          The number of bytes that have passed through this stream.
 int read()
          Increases the count by 1.
 int read(byte[] b)
          Increases the count by super.read(b)'s return count
 int read(byte[] b, int off, int len)
          Increases the count by super.read(b, off, len)'s return count
 
Methods inherited from class org.apache.commons.io.input.ProxyInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountingInputStream

public CountingInputStream(InputStream in)
Constructs a new CountingInputStream.

Parameters:
in - InputStream to delegate to
Method Detail

read

public int read(byte[] b)
         throws IOException
Increases the count by super.read(b)'s return count

Overrides:
read in class ProxyInputStream
Throws:
IOException
See Also:
InputStream.read(byte[])

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Increases the count by super.read(b, off, len)'s return count

Overrides:
read in class ProxyInputStream
Throws:
IOException
See Also:
InputStream.read(byte[], int, int)

read

public int read()
         throws IOException
Increases the count by 1.

Overrides:
read in class ProxyInputStream
Throws:
IOException
See Also:
InputStream.read()

getCount

public int getCount()
The number of bytes that have passed through this stream.

Returns:
the number of bytes accumulated


Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.