Return to Snippet

Revision: 20131
at November 8, 2009 16:29 by akufun


Initial Code
import java.io.*;

public class ReadString {

   public static void main (String[] args) {

      //  prompt the user to enter their name
      System.out.print("Enter your name: ");

      //  open up standard input
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      String userName = null;

      //  read the username from the command-line; need to use try/catch with the
      //  readLine() method
      try {
         userName = br.readLine();
      } catch (IOException ioe) {
         System.out.println("IO error trying to read your name!");
         System.exit(1);
      }

      System.out.println("Thanks for the name, " + userName);

   }

}  // end of ReadString class

Initial URL


Initial Description
Shows entire way using which input can be taken in java. As such it is a headache to take input in java

Initial Title
Keyboard input interface in Java for Desktop Application

Initial Tags


Initial Language
Java