try { int a = be.nextInt(); } catch (Exception e) { System.out.println("Nem egész szám!"); }