01: // Copyright (c) 2002 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.lists;
05:
06: import java.io.*;
07:
08: /** A Writer that wraps (filters) a Consumer. */
09:
10: public class ConsumerWriter extends Writer {
11: protected Consumer out;
12:
13: public ConsumerWriter(Consumer out) {
14: this .out = out;
15: }
16:
17: public void write(char[] buffer, int offset, int length) {
18: out.write(buffer, offset, length);
19: }
20:
21: public void flush() {
22: }
23:
24: public void close() {
25: // out.endDocument(); ???
26: flush();
27: }
28:
29: public void finalize() {
30: close();
31: }
32: }
|