1 |
The buffered output construct in the previous foil is of limited use since BufferedWriter has so few output methods. Instead, use the "monster" chain:
|
2 |
PrintWriter out =
-
new PrintWriter(
-
new BufferedWriter(
-
new OutputStreamWriter(
-
new FileOutputStream( filename ) ) ) );
|
3 |
which can be shortened somewhat by using FileWriter as shown earlier.
|
4 |
The PrintWriter class defines print(...) and println(...) methods for all primitive types, which unlike other Reader/Writer classes never throw exceptions.
|