SysReader Class
import java.io.*;
/* SysReader
This class provides a simple interface to the System.in object
and allows easier to use read() methods. There is LITTLE to NO
error checking, use with caution!
Public Methods:
String readLine() : read an entire line
char readChar() : read the next character
int readInt() : read a line and convert to int
double readDouble() : read a line and convert to double
void skip(int) : skip next 'int' bytes of input
*/
class SysReader {
BufferedReader stdin = null;
public SysReader() {
InputStreamReader is = new InputStreamReader(System.in);
stdin = new BufferedReader(is);
}
public String readLine() {
String theInput = null;
try {
theInput = stdin.readLine();
}
catch (IOException e) {
}
return theInput;
}
public char readChar() {
int ch = 0;
try {
ch = stdin.read();
}
catch (IOException e) {
}
return (char)ch;
}
public int readInt() {
int i = 0;
String theInput = readLine();
try {
i = Integer.parseInt(theInput);
}
catch (NumberFormatException e) {
}
return i;
}
public double readDouble() {
double x = 0.0;
String theInput = readLine();
try {
Double temp = new Double(theInput);
x = temp.doubleValue();
}
catch (NumberFormatException e) {
}
return x;
}
public void skip(int count) {
boolean ioError = false;
for (int i = 0; i < count && (!ioError); i++) {
try {
// skip over the CR/LF to set up for the next input
// skip 1 for Mac, 2 for DOS/Win, 1 for UNIX
stdin.skip(1);
}
catch (IOException e) {
ioError = true;
}
}
return;
}
}