Cierra el búfer

This commit is contained in:
2026-09-25 16:39:28 +02:00
parent 5666e0d653
commit bbf8609bbd
@@ -32,7 +32,10 @@ public class AppPrincipal {
File ficheroPaises = new File(RUTA_FICHERO); File ficheroPaises = new File(RUTA_FICHERO);
BufferedReader reader = null; BufferedReader reader = null;
try { try {
// Se carga la información del fichero en el búfer
reader = new BufferedReader(new FileReader(ficheroPaises)); reader = new BufferedReader(new FileReader(ficheroPaises));
// Mientras el búfer esté preparado
while (reader.ready()) { while (reader.ready()) {
String linea = reader.readLine(); String linea = reader.readLine();
@@ -61,6 +64,10 @@ public class AppPrincipal {
String sentenciaSQL = String.format("INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES (%d, '%s', '%s', '%s');", pais.getIdentificador(), pais.getContinente().getCodigo(), pais.getCapital(), pais.getNombre()); String sentenciaSQL = String.format("INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES (%d, '%s', '%s', '%s');", pais.getIdentificador(), pais.getContinente().getCodigo(), pais.getCapital(), pais.getNombre());
System.out.println(sentenciaSQL); System.out.println(sentenciaSQL);
// Se cierra el búfer.
reader.close();
} }
} }
} catch (IOException e) { } catch (IOException e) {