jtulach@1385
|
1 |
/*
|
jtulach@1385
|
2 |
* Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
|
jtulach@1385
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
jtulach@1385
|
4 |
*
|
jtulach@1385
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
jtulach@1385
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
jtulach@1385
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
jtulach@1385
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
jtulach@1385
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
jtulach@1385
|
10 |
*
|
jtulach@1385
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
jtulach@1385
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
jtulach@1385
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
jtulach@1385
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
jtulach@1385
|
15 |
* accompanied this code).
|
jtulach@1385
|
16 |
*
|
jtulach@1385
|
17 |
* You should have received a copy of the GNU General Public License version
|
jtulach@1385
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
jtulach@1385
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
jtulach@1385
|
20 |
*
|
jtulach@1385
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
jtulach@1385
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
jtulach@1385
|
23 |
* questions.
|
jtulach@1385
|
24 |
*/
|
jtulach@1385
|
25 |
|
jtulach@1385
|
26 |
package java.io;
|
jtulach@1385
|
27 |
|
jtulach@1385
|
28 |
|
jtulach@1385
|
29 |
/**
|
jtulach@1385
|
30 |
* Abstract class for writing filtered character streams.
|
jtulach@1385
|
31 |
* The abstract class <code>FilterWriter</code> itself
|
jtulach@1385
|
32 |
* provides default methods that pass all requests to the
|
jtulach@1385
|
33 |
* contained stream. Subclasses of <code>FilterWriter</code>
|
jtulach@1385
|
34 |
* should override some of these methods and may also
|
jtulach@1385
|
35 |
* provide additional methods and fields.
|
jtulach@1385
|
36 |
*
|
jtulach@1385
|
37 |
* @author Mark Reinhold
|
jtulach@1385
|
38 |
* @since JDK1.1
|
jtulach@1385
|
39 |
*/
|
jtulach@1385
|
40 |
|
jtulach@1385
|
41 |
public abstract class FilterWriter extends Writer {
|
jtulach@1385
|
42 |
|
jtulach@1385
|
43 |
/**
|
jtulach@1385
|
44 |
* The underlying character-output stream.
|
jtulach@1385
|
45 |
*/
|
jtulach@1385
|
46 |
protected Writer out;
|
jtulach@1385
|
47 |
|
jtulach@1385
|
48 |
/**
|
jtulach@1385
|
49 |
* Create a new filtered writer.
|
jtulach@1385
|
50 |
*
|
jtulach@1385
|
51 |
* @param out a Writer object to provide the underlying stream.
|
jtulach@1385
|
52 |
* @throws NullPointerException if <code>out</code> is <code>null</code>
|
jtulach@1385
|
53 |
*/
|
jtulach@1385
|
54 |
protected FilterWriter(Writer out) {
|
jtulach@1385
|
55 |
super(out);
|
jtulach@1385
|
56 |
this.out = out;
|
jtulach@1385
|
57 |
}
|
jtulach@1385
|
58 |
|
jtulach@1385
|
59 |
/**
|
jtulach@1385
|
60 |
* Writes a single character.
|
jtulach@1385
|
61 |
*
|
jtulach@1385
|
62 |
* @exception IOException If an I/O error occurs
|
jtulach@1385
|
63 |
*/
|
jtulach@1385
|
64 |
public void write(int c) throws IOException {
|
jtulach@1385
|
65 |
out.write(c);
|
jtulach@1385
|
66 |
}
|
jtulach@1385
|
67 |
|
jtulach@1385
|
68 |
/**
|
jtulach@1385
|
69 |
* Writes a portion of an array of characters.
|
jtulach@1385
|
70 |
*
|
jtulach@1385
|
71 |
* @param cbuf Buffer of characters to be written
|
jtulach@1385
|
72 |
* @param off Offset from which to start reading characters
|
jtulach@1385
|
73 |
* @param len Number of characters to be written
|
jtulach@1385
|
74 |
*
|
jtulach@1385
|
75 |
* @exception IOException If an I/O error occurs
|
jtulach@1385
|
76 |
*/
|
jtulach@1385
|
77 |
public void write(char cbuf[], int off, int len) throws IOException {
|
jtulach@1385
|
78 |
out.write(cbuf, off, len);
|
jtulach@1385
|
79 |
}
|
jtulach@1385
|
80 |
|
jtulach@1385
|
81 |
/**
|
jtulach@1385
|
82 |
* Writes a portion of a string.
|
jtulach@1385
|
83 |
*
|
jtulach@1385
|
84 |
* @param str String to be written
|
jtulach@1385
|
85 |
* @param off Offset from which to start reading characters
|
jtulach@1385
|
86 |
* @param len Number of characters to be written
|
jtulach@1385
|
87 |
*
|
jtulach@1385
|
88 |
* @exception IOException If an I/O error occurs
|
jtulach@1385
|
89 |
*/
|
jtulach@1385
|
90 |
public void write(String str, int off, int len) throws IOException {
|
jtulach@1385
|
91 |
out.write(str, off, len);
|
jtulach@1385
|
92 |
}
|
jtulach@1385
|
93 |
|
jtulach@1385
|
94 |
/**
|
jtulach@1385
|
95 |
* Flushes the stream.
|
jtulach@1385
|
96 |
*
|
jtulach@1385
|
97 |
* @exception IOException If an I/O error occurs
|
jtulach@1385
|
98 |
*/
|
jtulach@1385
|
99 |
public void flush() throws IOException {
|
jtulach@1385
|
100 |
out.flush();
|
jtulach@1385
|
101 |
}
|
jtulach@1385
|
102 |
|
jtulach@1385
|
103 |
public void close() throws IOException {
|
jtulach@1385
|
104 |
out.close();
|
jtulach@1385
|
105 |
}
|
jtulach@1385
|
106 |
|
jtulach@1385
|
107 |
}
|