Project JXTA

net.jxta.util
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by net.jxta.util.CountingInputStream
All Implemented Interfaces:
Closeable

public class CountingInputStream
extends FilterInputStream

A filter input stream which counts the bytes read from the stream. A filter so that you don't have to count seperately from reading from the inoput


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CountingInputStream(InputStream in)
          Make a new Counting Input Stream
 
Method Summary
 long getBytesRead()
          Returns the number of bytes read fromthe stream thus far.
 int read()
          

Merely calls the super version.

 int read(byte[] b, int off, int len)
          

calls the super version of the same method.

 String toString()
          

Debugging toString.

 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountingInputStream

public CountingInputStream(InputStream in)
Make a new Counting Input Stream

Method Detail

toString

public String toString()

Debugging toString.

Overrides:
toString in class Object

read

public int read()
         throws IOException

Merely calls the super version.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

calls the super version of the same method.

Overrides:
read in class FilterInputStream
Throws:
IOException

getBytesRead

public long getBytesRead()
Returns the number of bytes read fromthe stream thus far. This and all the methods in this class are synchronized because bytesRead cannot be volatile.

Returns:
long containing the number of bytes read.

JXTA J2SE