/* Reading and verifying an integer string */ import java.io.*; class str2int { public static void main (String[] args) throws IOException { int val = 0, i; String num; char ch; boolean ok = true; BufferedReader stdin; stdin = new BufferedReader (new InputStreamReader (System.in)); System.out.print ("Type an integer: "); num = stdin.readLine(); for (i=0; (i= 48 & ch <= 57) val = 10 * val + ch - 48; else ok = false; } if (ok) System.out.println ("The value is: " + val); else System.out.println ("Wrong input"); } }