Specifications

Sun Services
Java™ Programming Language
Module 9, slide 12 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Reading From Standard Input
1 import java.io.*;
2
3 public class KeyboardInput {
4 public static void main (String args[]) {
5 String s;
6 // Create a buffered reader to read
7 // each line from the keyboard.
8 InputStreamReader ir
9 = new InputStreamReader(System.in);
10 BufferedReader in = new BufferedReader(ir);
11
12 System.out.println("Unix: Type ctrl-d to exit." +
13 "\nWindows: Type ctrl-z to exit");