This should help you for scanning Integer values.
try{
System.out.print("Enter an integer: ");
int number = input.nextInt();
}
catch (InputMismatchException ex) {
System.out.println("Incorrect input: an integer is required)");
//It's also possible to throw your custom Exception here, like "throw new CustomException();"
}
About the IndexOutOfBoundsException, just write a try catch block around the area, where you expect that exception and throw your own custom exception.
try{
...
}catch(IndexOutOfBoundsException e){
throw CustomException2();
}
solved Creating custom java exception [duplicate]