samples/delegatingwriterfinal/src-test2.0/api/usage/twodotzero/CountingWriter.java
Tests rewritten to new version, just the Writer version 2.0 does not yet implement Appendable
2 package api.usage.twodotzero;
5 import java.io.IOException;
6 import java.util.concurrent.atomic.AtomicInteger;
8 /** Writer that counts the number of written in characters.
10 * @author Jaroslav Tulach
12 public class CountingWriter implements Writer.ImplSeq {
13 private final AtomicInteger counter;
15 private CountingWriter(AtomicInteger counter) {
16 this.counter = counter;
19 public static Writer create(AtomicInteger result) {
20 return Writer.create(new CountingWriter(result));
24 public void write(CharSequence csq) throws IOException {
25 counter.addAndGet(csq.length());
29 public void flush() throws IOException {
33 public void close() throws IOException {