This code gives me an error when I take more than one data by keyboard in the same application, it gives an IOException error;
gives error when leaving the do while
I don't know why he makes this kind of mistake.
public static String datoString() {
// Entorno:
BufferedReader br;
String frase;
boolean esCorrecto;
//Algoritmo
frase=null;
br = new BufferedReader(new InputStreamReader(System.in));
try {
do {
System.out.println("Introduce una cadena");
frase = br.readLine();
esCorrecto = true;
} while (!esCorrecto);
} catch (IOException ioe) {
System.err.println("Error I/O");
}
try {
br.close();
} catch (IOException ioe2) {
ioe2.printStackTrace();
}//Fin try
return frase;
}
br.close();you can no longer useSystem.inin another call todatoString()