Basic HTML version of Foils prepared 17 Nov 97

Foil 29 Standard Input/Output

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

Standard Input/Output for Foil 29
1 The System class in java.lang provides the "standard" IO streams System.in, System.out, and System.err.
2 System.in is an instance of InputStream.
3 System.out and System.err are instances of PrintStream.
4 PrintStream is a subclass of FilterOutputStream, which itself is a subclass of OutputStream. (See next foil.) PrintStream objects should not be instantiated; use other subclasses of FilterOutputStream for byte streams or PrintWriter objects for character streams.
5 PrintStream and PrintWriter define methods print(...) and println(...), which output any primitive type:
6 System.out.println( "Enter character: " );
7 int ch = System.in.read();
8 System.out.println( (char) ch );

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