import java.io.*; import java.util.*; public class Lecture { private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static int [] lireEntiers(int n) { String chaine; try { chaine = in.readLine(); } catch (IOException e) { throw new Error(e.getMessage()); } StringTokenizer analyse = new StringTokenizer(chaine); int [] t = new int[n]; for (int i = 0; i < n; i++) { try { t[i] = Integer.parseInt(analyse.nextToken()); } catch (NoSuchElementException e) { return relance(n); } catch (NumberFormatException e) { return relance(n); } } if (analyse.hasMoreTokens()) { return relance(n); } return t; } private static int [] relance(int n) { System.out.println("Ligne incorrecte, recommencez !"); return lireEntiers(n); } }