import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; /** get a string from the user using the command line. @author Greg Vogl 2003-09-21 */ public class ConsoleString { /** get a string from the user using the command line.
input: a string using the command line
output: the string @throws IOException to handle bad strings */ public static void main (String[] args) throws IOException { System.out.println("Enter a string:"); BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); String input = console.readLine(); // get a string from the user System.out.println("You entered: " + input); // display the string to the screen } }