2 package org.apidesign.delegatingwriter;
4 import java.io.IOException;
7 // BEGIN: writer.CountingWriter
8 /** Writer that counts the number of written in characters.
10 public class CountingWriter extends Writer {
14 public int getCharacterCount() {
19 public void write(char[] cbuf, int off, int len) throws IOException {
24 public Writer append(CharSequence csq) throws IOException {
25 counter += csq.length();
28 // FINISH: writer.CountingWriter
31 public Writer append(CharSequence csq, int start, int end) throws IOException {
32 counter += (end - start);
37 public Writer append(char c) throws IOException {
43 public void write(int c) throws IOException {
48 public void write(char[] cbuf) throws IOException {
49 counter += cbuf.length;
53 public void write(String str) throws IOException {
54 counter += str.length();
58 public void write(String str, int off, int len) throws IOException {
63 public void flush() throws IOException {
67 public void close() throws IOException {