You can use some if-else statements to test/qualify the iuput.
For example,
BufferedReader reader = ...
int n = -1;
do {
System.out.println("enter 1 or 2");
String line = reader.readLine();
if(line != null && line.length() > 0) {
// User entered something so we may have something to parse.
// You may want to check that "line" contains parsable digits
// with something like Character.isDigit.
// Or, you could use a try/catch for NumberFormatException.
n = Integer.parseInt(line);
}
} while(n != 1 && n != 2);