2
|
1 |
/*
|
|
2 |
* Copyright 1996-2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package java.io;
|
|
27 |
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Abstract class for reading filtered character streams.
|
|
31 |
* The abstract class <code>FilterReader</code> itself
|
|
32 |
* provides default methods that pass all requests to
|
|
33 |
* the contained stream. Subclasses of <code>FilterReader</code>
|
|
34 |
* should override some of these methods and may also provide
|
|
35 |
* additional methods and fields.
|
|
36 |
*
|
|
37 |
* @author Mark Reinhold
|
|
38 |
* @since JDK1.1
|
|
39 |
*/
|
|
40 |
|
|
41 |
public abstract class FilterReader extends Reader {
|
|
42 |
|
|
43 |
/**
|
|
44 |
* The underlying character-input stream.
|
|
45 |
*/
|
|
46 |
protected Reader in;
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Creates a new filtered reader.
|
|
50 |
*
|
|
51 |
* @param in a Reader object providing the underlying stream.
|
|
52 |
* @throws NullPointerException if <code>in</code> is <code>null</code>
|
|
53 |
*/
|
|
54 |
protected FilterReader(Reader in) {
|
|
55 |
super(in);
|
|
56 |
this.in = in;
|
|
57 |
}
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Reads a single character.
|
|
61 |
*
|
|
62 |
* @exception IOException If an I/O error occurs
|
|
63 |
*/
|
|
64 |
public int read() throws IOException {
|
|
65 |
return in.read();
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Reads characters into a portion of an array.
|
|
70 |
*
|
|
71 |
* @exception IOException If an I/O error occurs
|
|
72 |
*/
|
|
73 |
public int read(char cbuf[], int off, int len) throws IOException {
|
|
74 |
return in.read(cbuf, off, len);
|
|
75 |
}
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Skips characters.
|
|
79 |
*
|
|
80 |
* @exception IOException If an I/O error occurs
|
|
81 |
*/
|
|
82 |
public long skip(long n) throws IOException {
|
|
83 |
return in.skip(n);
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Tells whether this stream is ready to be read.
|
|
88 |
*
|
|
89 |
* @exception IOException If an I/O error occurs
|
|
90 |
*/
|
|
91 |
public boolean ready() throws IOException {
|
|
92 |
return in.ready();
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Tells whether this stream supports the mark() operation.
|
|
97 |
*/
|
|
98 |
public boolean markSupported() {
|
|
99 |
return in.markSupported();
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Marks the present position in the stream.
|
|
104 |
*
|
|
105 |
* @exception IOException If an I/O error occurs
|
|
106 |
*/
|
|
107 |
public void mark(int readAheadLimit) throws IOException {
|
|
108 |
in.mark(readAheadLimit);
|
|
109 |
}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Resets the stream.
|
|
113 |
*
|
|
114 |
* @exception IOException If an I/O error occurs
|
|
115 |
*/
|
|
116 |
public void reset() throws IOException {
|
|
117 |
in.reset();
|
|
118 |
}
|
|
119 |
|
|
120 |
public void close() throws IOException {
|
|
121 |
in.close();
|
|
122 |
}
|
|
123 |
|
|
124 |
}
|