Incorporating Patrick's changes. I am not reall sure about the changes after the war, it is really 'or' it cannot be 'and'. I will change that when I do the reading through the whole chapter.
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 * @author Jaroslav Tulach
12 public class CountingWriter extends Writer {
16 public int getCharacterCount() {
21 public void write(char[] cbuf, int off, int len) throws IOException {
26 public Writer append(CharSequence csq) throws IOException {
27 counter += csq.length();
30 // FINISH: writer.CountingWriter
33 public Writer append(CharSequence csq, int start, int end) throws IOException {
34 counter += (end - start);
39 public Writer append(char c) throws IOException {
45 public void write(int c) throws IOException {
50 public void write(char[] cbuf) throws IOException {
51 counter += cbuf.length;
55 public void write(String str) throws IOException {
56 counter += str.length();
60 public void write(String str, int off, int len) throws IOException {
65 public void flush() throws IOException {
69 public void close() throws IOException {