Scanner conin = new Scanner(System.in); int i; // Read a list of integers. while(conin.hasNextInt()) { i = conin.nextInt(); // ... }