samples/delegatingwriterfinal/src-test2.0/api/usage/twodotzero/CountingWriter.java
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 public class CountingWriter implements Writer.ImplSeq {
11 private final AtomicInteger counter;
13 private CountingWriter(AtomicInteger counter) {
14 this.counter = counter;
17 public static Writer create(AtomicInteger result) {
18 return Writer.create(new CountingWriter(result));
22 public void write(CharSequence csq) throws IOException {
23 counter.addAndGet(csq.length());
27 public void flush() throws IOException {
31 public void close() throws IOException {