JXTA

net.jxta.util
Class CountingWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.FilterWriter
          extended by net.jxta.util.CountingWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class CountingWriter
extends FilterWriter

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


Field Summary
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
CountingWriter(Writer out)
          Creates a new instance of CountingWriter
 
Method Summary
 long getCharsWritten()
          Returns the number of chars written to the stream thus far.
 String toString()
          

Debugging toString.

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

Calls the super version of the same method.

 void write(int b)
          

Calls the super version of the same method.

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

Constructor Detail

CountingWriter

public CountingWriter(Writer out)
Creates a new instance of CountingWriter

Method Detail

toString

public String toString()

Debugging toString.

Overrides:
toString in class Object

write

public void write(int b)
           throws IOException

Calls the super version of the same method.

Overrides:
write in class FilterWriter
Throws:
IOException

write

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

Calls the super version of the same method.

Overrides:
write in class FilterWriter
Throws:
IOException

getCharsWritten

public long getCharsWritten()
Returns the number of chars 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.

JXSE