// File: ScreenIO1.java // // Author: Rahul Simha // Created: Aug 17, 1998 // // Demonstrates reading a line of input from the screen. import java.io.*; public class ScreenIO1 { public static void main (String[] argv) { // Put out a prompt. System.out.print ("Enter string: "); // We have to have a try clause because // the function readLine throws an exception. try { // These are the key steps in setting up the read operation. InputStreamReader isr = new InputStreamReader (System.in); LineNumberReader lr = new LineNumberReader (isr); // Now read the input line. String inputLine = lr.readLine (); // Echo it. System.out.println ("Echo: " + inputLine); } catch (IOException e) { // If there was a problem... System.out.println (e); } } }