Basic HTML version of Foils prepared 17 Nov 97

Foil 36 Character Streams

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo

Reader/Writer classes for Foil 36
Java 1.1 introduced Reader and Writer classes for character streams, which are used to read/write text files.
To construct a character output stream, for example:
PrintWriter out =
  • new PrintWriter(
  • new OutputStreamWriter(
  • new FileOutputStream( filename ) ) );
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.



© 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 Wed Apr 1 1998