ConsumerWriter.java 601 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2002 Per M.A. Bothner.
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.lists;
  4. import java.io.*;
  5. /** A Writer that wraps (filters) a Consumer. */
  6. public class ConsumerWriter extends Writer
  7. {
  8. protected Consumer out;
  9. public ConsumerWriter(Consumer out)
  10. {
  11. this.out = out;
  12. }
  13. public void write(char[] buffer, int offset, int length)
  14. {
  15. out.write(buffer, offset, length);
  16. }
  17. public void flush() { }
  18. public void close()
  19. {
  20. // out.endDocument(); ???
  21. flush();
  22. }
  23. public void finalize()
  24. {
  25. close();
  26. }
  27. }