blob: 90c8ab749b8636c0ca41cca48116cd985d293d88 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
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
26package java.io;
27
28
29/**
30 * Abstract class for writing filtered character streams.
31 * The abstract class <code>FilterWriter</code> itself
32 * provides default methods that pass all requests to the
33 * contained stream. Subclasses of <code>FilterWriter</code>
34 * should override some of these methods and may also
35 * provide additional methods and fields.
36 *
37 * @author Mark Reinhold
38 * @since JDK1.1
39 */
40
41public abstract class FilterWriter extends Writer {
42
43 /**
44 * The underlying character-output stream.
45 */
46 protected Writer out;
47
48 /**
49 * Create a new filtered writer.
50 *
51 * @param out a Writer object to provide the underlying stream.
52 * @throws NullPointerException if <code>out</code> is <code>null</code>
53 */
54 protected FilterWriter(Writer out) {
55 super(out);
56 this.out = out;
57 }
58
59 /**
60 * Writes a single character.
61 *
62 * @exception IOException If an I/O error occurs
63 */
64 public void write(int c) throws IOException {
65 out.write(c);
66 }
67
68 /**
69 * Writes a portion of an array of characters.
70 *
71 * @param cbuf Buffer of characters to be written
72 * @param off Offset from which to start reading characters
73 * @param len Number of characters to be written
74 *
75 * @exception IOException If an I/O error occurs
76 */
77 public void write(char cbuf[], int off, int len) throws IOException {
78 out.write(cbuf, off, len);
79 }
80
81 /**
82 * Writes a portion of a string.
83 *
84 * @param str String to be written
85 * @param off Offset from which to start reading characters
86 * @param len Number of characters to be written
87 *
88 * @exception IOException If an I/O error occurs
89 */
90 public void write(String str, int off, int len) throws IOException {
91 out.write(str, off, len);
92 }
93
94 /**
95 * Flushes the stream.
96 *
97 * @exception IOException If an I/O error occurs
98 */
99 public void flush() throws IOException {
100 out.flush();
101 }
102
103 public void close() throws IOException {
104 out.close();
105 }
106
107}