Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { System.out.println(scanner.nextInt()); }