Project JXTA

net.jxta.util
Class CountingOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended bynet.jxta.util.CountingOutputStream

public class CountingOutputStream
extends FilterOutputStream

A filter output stream which counts the bytes sent to the stream. A filter so that you don't have to count seperately from writing to the output


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
CountingOutputStream(OutputStream out)
          Creates a new instance of CountingOutputStream
 
Method Summary
 long getBytesWritten()
          Returns the number of bytes written to the stream thus far.
 String toString()
          

Debugging toString.

 void write(byte[] b, int off, int len)
          

calls the super version of the same method.

 void write(int b)
          

Merely calls the super version.

 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountingOutputStream

public CountingOutputStream(OutputStream out)
Creates a new instance of CountingOutputStream

Method Detail

toString

public String toString()

Debugging toString.


write

public void write(int b)
           throws IOException

Merely calls the super version.

Throws:
IOException

write

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

calls the super version of the same method.

Throws:
IOException

getBytesWritten

public long getBytesWritten()
Returns the number of bytes written to the stream thus far. This and all the methods in this class are synchronized because bytesWritten cannot be volatile.

Returns:
long containing the number of bytes written.

JXTA J2SE