1. /*
  2. * @(#)FilterReader.java 1.17 03/12/19
  3. *
  4. * Copyright 2004 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 reading filtered character streams.
  10. * The abstract class <code>FilterReader</code> itself
  11. * provides default methods that pass all requests to
  12. * the contained stream. Subclasses of <code>FilterReader</code>
  13. * should override some of these methods and may also provide
  14. * additional methods and fields.
  15. *
  16. * @version 1.17, 03/12/19
  17. * @author Mark Reinhold
  18. * @since JDK1.1
  19. */
  20. public abstract class FilterReader extends Reader {
  21. /**
  22. * The underlying character-input stream.
  23. */
  24. protected Reader in;
  25. /**
  26. * Create a new filtered reader.
  27. *
  28. * @param in a Reader object providing the underlying stream.
  29. * @throws NullPointerException if <code>in</code> is <code>null</code>
  30. */
  31. protected FilterReader(Reader in) {
  32. super(in);
  33. this.in = in;
  34. }
  35. /**
  36. * Read a single character.
  37. *
  38. * @exception IOException If an I/O error occurs
  39. */
  40. public int read() throws IOException {
  41. return in.read();
  42. }
  43. /**
  44. * Read characters into a portion of an array.
  45. *
  46. * @exception IOException If an I/O error occurs
  47. */
  48. public int read(char cbuf[], int off, int len) throws IOException {
  49. return in.read(cbuf, off, len);
  50. }
  51. /**
  52. * Skip characters.
  53. *
  54. * @exception IOException If an I/O error occurs
  55. */
  56. public long skip(long n) throws IOException {
  57. return in.skip(n);
  58. }
  59. /**
  60. * Tell whether this stream is ready to be read.
  61. *
  62. * @exception IOException If an I/O error occurs
  63. */
  64. public boolean ready() throws IOException {
  65. return in.ready();
  66. }
  67. /**
  68. * Tell whether this stream supports the mark() operation.
  69. */
  70. public boolean markSupported() {
  71. return in.markSupported();
  72. }
  73. /**
  74. * Mark the present position in the stream.
  75. *
  76. * @exception IOException If an I/O error occurs
  77. */
  78. public void mark(int readAheadLimit) throws IOException {
  79. in.mark(readAheadLimit);
  80. }
  81. /**
  82. * Reset the stream.
  83. *
  84. * @exception IOException If an I/O error occurs
  85. */
  86. public void reset() throws IOException {
  87. in.reset();
  88. }
  89. /**
  90. * Close the stream.
  91. *
  92. * @exception IOException If an I/O error occurs
  93. */
  94. public void close() throws IOException {
  95. in.close();
  96. }
  97. }