1 |
Java 1.1 introduced Reader and Writer classes for character streams, which are used to read/write text files.
|
2 |
To construct a character output stream, for example:
|
3 |
PrintWriter out =
-
new PrintWriter(
-
new OutputStreamWriter(
-
new FileOutputStream( filename ) ) );
|
4 |
The OutputStreamWriter constructor takes a byte stream and converts it to a character stream. As a shortcut, use
|
5 |
PrintWriter out =
-
new PrintWriter(
-
new FileWriter( filename ) );
|
6 |
where FileWriter is a subclass of OutputStreamWriter.
|