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
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.

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