import java.io.*; /** * Echo.java *
* A class to demonstrate terminal I/O. *
* Created: Fri Feb 7 07:49:50 2003 * * @author Stuart C. Shapiro */ public class Echo { /** * A demonstration of a Read/Print loop, * and the recognition of IOException. * * @param args a String[] value * @exception IOException if an error occurs */ public static void main (String[] args) throws IOException { String input; BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Say something (\"Bye\" to end): "); input = reader.readLine(); while (!(input == null || input.equals("Bye"))) { System.out.println("You said =>" + input + "<="); System.out.print("Say something (\"Bye\" to end): "); input = reader.readLine(); } // end of while (true) System.out.println("Goodbye."); } // end of main () }// Echo