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