Basic HTML version of Foils prepared Sept 21 1998

Foil 33 Character Streams

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

Reader/Writer classes for Foil 33
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:
  • PrintWriter out =
  • new PrintWriter(
  • new OutputStreamWriter(
  • new FileOutputStream( filename ) ) );
3 The OutputStreamWriter constructor takes a byte stream and converts it to a character stream. As a shortcut, use
  • PrintWriter out =
  • new PrintWriter(
  • new FileWriter( filename ) );
  • where FileWriter is a subclass of OutputStreamWriter.

in Table To:


© 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