//************************************** // Name: Read a string from the command line // Description:reads a string from the command line. Should be easy but it wasnt explained well so I wrote this. // By: Chad Neal (from psc cd) // // // Inputs:text // // Returns:text // //Assumes:None // //Side Effects:I am using jdk 1.4 so I am not sure of compat problems ;( //************************************** // hello <string> import java.io.*; public class hello { public static void main(String[] args) { //setup global vars (bad) String userName = null; //setup input buffer BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //do my stuff System.out.print("\nWhats your name?\n\n"); //make sure to cath errors (they happen often with this ;( ) try { userName = br.readLine(); } catch (IOException ioerror) { System.out.println("IO error trying to read your name!"); System.exit(1); } System.out.print("\n\n\nHello " + userName + "!!!\n\n\n"); } }