:
Scanner sc = new Scanner(System.in);
sc.useDelimiter(System.getProperty("line.separator"));
while (sc.hasNextInt()){
int i = sc.nextInt();
}
UPDATE:
, , . enter, , .
(, ), , , :
Scanner sc = new Scanner(System.in);
Pattern delimiters = Pattern.compile(System.getProperty("line.separator")+"|\\s");
sc.useDelimiter(delimiters);
while (sc.hasNextInt()){
int i = sc.nextInt();
System.out.println("Scanned: "+i);
}
Pattern . . , , , Enter, . . , Enter, . , , .