1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/delegatingwriterfinal/src-api1.0/api/SimpleBuffer.java Sat Jun 14 09:53:07 2008 +0200
1.3 @@ -0,0 +1,36 @@
1.4 +package api;
1.5 +
1.6 +import java.io.IOException;
1.7 +
1.8 +/**
1.9 + *
1.10 + * @author Jaroslav Tulach
1.11 + */
1.12 +final class SimpleBuffer implements Writer.Impl {
1.13 + private final Writer out;
1.14 + private final StringBuffer sb = new StringBuffer();
1.15 +
1.16 + public SimpleBuffer(Writer out) {
1.17 + this.out = out;
1.18 + }
1.19 +
1.20 + public void close() throws IOException {
1.21 + flush();
1.22 + out.close();
1.23 + }
1.24 +
1.25 + public void flush() throws IOException {
1.26 + out.write(sb.toString());
1.27 + sb.setLength(0);
1.28 + out.flush();
1.29 + }
1.30 +
1.31 + public void write(String str, int off, int len) throws IOException {
1.32 + sb.append(str, len, len);
1.33 + }
1.34 +
1.35 + public void write(char[] arr, int off, int len) throws IOException {
1.36 + sb.append(arr, len, len);
1.37 + }
1.38 +
1.39 +}