I have a file that I need to read, print out the integers, catch exception and continue with the next integer to display, and so on until there are no more integers.
When exception occurs, control get to the matching catch block and then subsequent line after that catch block. In your case matching catch is outside the while loop and hence while loop is stopped. Move the corresponding catch block in while loop. In your code reader.nextInt(); is the potential line which may cause the InputMismatchException.
try {
int num = reader.nextInt();
System.out.println("Number read: " +num);
} catch (InputMismatchException e) {
System.out.println("Input error ");
}