First, you can catch the exception and do something you want.
A better way is use Scanner.hasNextInt()
to test whether the line user input is a int.
System.out.println("Type a number");
while(!input.hasNextInt()) {
input.nextLine();
System.out.println("That is not a valid number. Try again");
}
number = input.nextInt();