1: // File: InputReader.java 2: // Methods for Reading char and int 3: // Package implemented. java directory in classpath. Package is named 4: // according to subdirectories of that directory. 5: 6: package Input; 7: 8: import java.io.*; 9: 10: public class InputReader { 11: 12: public static char readChar() throws java.io.IOException 13: { BufferedReader DataIn=new BufferedReader(new InputStreamReader(System.in)); 14: String Line; 15: do 16: Line=DataIn.readLine().trim(); 17: while (Line.length()==0); 18: return((Line.toUpperCase().toCharArray())[0]); 19: } 20: 21: public static char getChoice(String OK) throws java.io.IOException 22: {char Reply; 23: do { 24: Reply=readChar(); 25: } while (OK.indexOf(Reply,0)==-1); 26: return(Reply); 27: } 28: 29: public static int readInt() throws java.io.IOException 30: {BufferedReader DataIn = new BufferedReader(new InputStreamReader(System.in)); 31: String Input=DataIn.readLine(); 32: return (Integer.valueOf(Input).intValue()); 33: } 34: 35: } // end of ReadInput Class 36: } // end of ReadInput Class