import java.io.*; class pseudoKeyboard { // Author: M. Dennis Mickunas, June 9, 1997 // Primitive Keyboard input of integers, reals, // strings, and characters. // Modified for file input by Allen Tucker 10/98 static boolean iseof = false; static char c; static int i; static double d; static String s; static BufferedReader input; public pseudoKeyboard(String fileName) { try { input = new BufferedReader (new FileReader(fileName)); } catch (FileNotFoundException e) { System.out.println("File not found"); } } public static int readInt () { if (iseof) return 0; System.out.flush(); try { s = input.readLine(); } catch (IOException e) { System.exit(-1); } if (s.length()==0) { // ctrl-C iseof=true; return 0; } i = new Integer(s.trim()).intValue(); return i; } public static char readChar () { if (iseof) return (char)0; System.out.flush(); try { i = input.read(); } catch (IOException e) { System.exit(-1); } if (i == -1) { iseof=true; return (char)0; } return (char)i; } public static double readDouble () { if (iseof) return 0.0; System.out.flush(); try { s = input.readLine(); } catch (IOException e) { System.exit(-1); } if (s.length()==0) { iseof=true; return 0.0; } d = new Double(s.trim()).doubleValue(); return d; } public static String readString () { if (iseof) return null; System.out.flush(); try { s=input.readLine(); } catch (IOException e) { System.exit(-1); } if (s==null) { iseof=true; return null; } return s; } public static boolean eof () { return iseof; } }