KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > io > FilterWriter


1 /*
2  * @(#)FilterWriter.java 1.16 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
8 package java.io;
9
10
11 /**
12  * Abstract class for writing filtered character streams.
13  * The abstract class <code>FilterWriter</code> itself
14  * provides default methods that pass all requests to the
15  * contained stream. Subclasses of <code>FilterWriter</code>
16  * should override some of these methods and may also
17  * provide additional methods and fields.
18  *
19  * @version 1.16, 03/12/19
20  * @author Mark Reinhold
21  * @since JDK1.1
22  */

23
24 public abstract class FilterWriter extends Writer JavaDoc {
25
26     /**
27      * The underlying character-output stream.
28      */

29     protected Writer JavaDoc out;
30
31     /**
32      * Create a new filtered writer.
33      *
34      * @param out a Writer object to provide the underlying stream.
35      * @throws NullPointerException if <code>out</code> is <code>null</code>
36      */

37     protected FilterWriter(Writer JavaDoc out) {
38     super(out);
39     this.out = out;
40     }
41
42     /**
43      * Write a single character.
44      *
45      * @exception IOException If an I/O error occurs
46      */

47     public void write(int c) throws IOException JavaDoc {
48     out.write(c);
49     }
50
51     /**
52      * Write a portion of an array of characters.
53      *
54      * @param cbuf Buffer of characters to be written
55      * @param off Offset from which to start reading characters
56      * @param len Number of characters to be written
57      *
58      * @exception IOException If an I/O error occurs
59      */

60     public void write(char cbuf[], int off, int len) throws IOException JavaDoc {
61     out.write(cbuf, off, len);
62     }
63
64     /**
65      * Write a portion of a string.
66      *
67      * @param str String to be written
68      * @param off Offset from which to start reading characters
69      * @param len Number of characters to be written
70      *
71      * @exception IOException If an I/O error occurs
72      */

73     public void write(String JavaDoc str, int off, int len) throws IOException JavaDoc {
74     out.write(str, off, len);
75     }
76
77     /**
78      * Flush the stream.
79      *
80      * @exception IOException If an I/O error occurs
81      */

82     public void flush() throws IOException JavaDoc {
83     out.flush();
84     }
85
86     /**
87      * Close the stream.
88      *
89      * @exception IOException If an I/O error occurs
90      */

91     public void close() throws IOException JavaDoc {
92     out.close();
93     }
94
95 }
96
Popular Tags