1. /*
  2. * @(#)FilterWriter.java 1.9 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.io;
  8. /**
  9. * Abstract class for writing filtered character streams.
  10. *
  11. * @version 1.9, 01/11/29
  12. * @author Mark Reinhold
  13. * @since JDK1.1
  14. */
  15. public abstract class FilterWriter extends Writer {
  16. /**
  17. * The underlying character-output stream.
  18. */
  19. protected Writer out;
  20. /**
  21. * Create a new filtered writer.
  22. */
  23. protected FilterWriter(Writer out) {
  24. super(out);
  25. this.out = out;
  26. }
  27. /**
  28. * Write a single character.
  29. *
  30. * @exception IOException If an I/O error occurs
  31. */
  32. public void write(int c) throws IOException {
  33. out.write(c);
  34. }
  35. /**
  36. * Write a portion of an array of characters.
  37. *
  38. * @param cbuf Buffer of characters to be written
  39. * @param off Offset from which to start reading characters
  40. * @param len Number of characters to be written
  41. *
  42. * @exception IOException If an I/O error occurs
  43. */
  44. public void write(char cbuf[], int off, int len) throws IOException {
  45. out.write(cbuf, off, len);
  46. }
  47. /**
  48. * Write a portion of a string.
  49. *
  50. * @param str String to be written
  51. * @param off Offset from which to start reading characters
  52. * @param len Number of characters to be written
  53. *
  54. * @exception IOException If an I/O error occurs
  55. */
  56. public void write(String str, int off, int len) throws IOException {
  57. out.write(str, off, len);
  58. }
  59. /**
  60. * Flush the stream.
  61. *
  62. * @exception IOException If an I/O error occurs
  63. */
  64. public void flush() throws IOException {
  65. out.flush();
  66. }
  67. /**
  68. * Close the stream.
  69. *
  70. * @exception IOException If an I/O error occurs
  71. */
  72. public void close() throws IOException {
  73. out.close();
  74. }
  75. }