Basic HTML version of Foils prepared Sept 21 1998

Foil 35 A Monster Chain

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

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



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998