Project JXTA

net.jxta.util
Class CountingInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bynet.jxta.util.CountingInputStream

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.


read

public int read()
         throws IOException

Merely calls the super version.

Throws:
IOException

read

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

calls the super version of the same method.

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