Advertisement
cd62131

IntegerCheck

Feb 23rd, 2014
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.53 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3.  
  4. public class IntegerCheck {
  5.   public static void main(String[] args) {
  6.     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  7.     String s = null;
  8.     int x = -1;
  9.     while (true) {
  10.       try {
  11.         s = in.readLine();
  12.       }
  13.       catch (Exception e) {
  14.       }
  15.       if (s == null) continue;
  16.       try {
  17.         x = new Integer(s);
  18.       }
  19.       catch (Exception e) {
  20.       }
  21.       if (x == 1 || x == 2) break;
  22.     }
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement