import java.io.*; class iotest2 { private static void promptRead(BufferedReader stdin) throws IOException { System.out.print("Input a double: "); System.out.flush(); String inpline; if((inpline = stdin.readLine()) != null) { double i = Double.valueOf(inpline).doubleValue(); System.out.println("Double was " + i); } else System.out.println("Couldn't Read anything"); } public static void main(String[] argv) { BufferedReader stdin = new java.io.BufferedReader (new InputStreamReader(System.in)); boolean tryagain = true; while(tryagain) { tryagain = false; try { promptRead(stdin); } catch (IOException ioe) { System.out.println("Problem in the input stream"); } catch (NumberFormatException nfe) { System.out.println("Not a number. Try again."); tryagain = true; } } } }