/** * Vladimir Vacic, Betul Buyukkurt * Computer Science and Engineering Department * University of California, Riverside * * CS152 - Compiler Construction * * * * If you are not solving the extra credit error handling, you * can skip this note: * * But if you are, you probably do not want to catch some of the * exceptions here, but rather somewhere else. :) * */ import java.io.*; public class Input { public static Integer getDigit() { try { InputStreamReader in = new InputStreamReader(System.in); Integer userInput = new Integer(Character.digit(in.read(), 10)); return userInput; } catch(NumberFormatException e) {} catch(IOException e) {} return new Integer(0); } public static Integer getInt() { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Integer userInput = new Integer(in.readLine()); return userInput; } catch(NumberFormatException e) {} catch(IOException e) {} return new Integer(0); } }