import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RepeticionTryCatch{
public static int leer2Enteros(String mensaje) {
return leer2Enteros(mensaje, "");
}
public static int leer2Enteros(String mensaje, String error) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int suma;
try {
System.out.print(error + mensaje);
String numeros = br.readLine();
String[] n = numeros.split(" ");
suma = Integer.parseInt(n[0]) + Integer.parseInt(n[1]);
} catch (IOException | NumberFormatException ex) {
suma = leer2Enteros(mensaje.toLowerCase(), "Incorrecto, ");
}
return suma;
}
public static void main(String[] args) throws IOException {
int a = leer2Enteros("Introduce dos valores enteros: ");
System.out.println("La suma es: " + a);
}
}