this is the code we were given to read input from the command prompt window. it'll take the whole thing as a string until the enter key is pushed.
Code:
import java.io.*;
public class Keyboard {
private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static String readInput() {
try {
return in.readLine();
}
catch (IOException e) {
System.out.println("An error has occurred in the Keyboard.readInput() method");
System.out.println(e.toString());
System.exit(-1);
}
return null;
}
}
Basically it creates a buffered reader using System.in as the argument. then it'll read a line of text as return it.
and if an IO exception is caught then you'll know about it.
I prefer to live in my own shadow. At least then I can be compared to a false past I'm more familiar with
Bookmarks