Mega Code Archive
In general, to use Scanner, follow this procedure
Call one of Scanner's hasNextXXX methods to see if the input is available
If available, call Scanner's nextXXX to read the input.
Repeat first two steps.
Scanner conin = new Scanner(System.in);
int i;
// Read a list of integers.
while(conin.hasNextInt()) {
i = conin.nextInt();
// ...
}