Incluye try-with-resources
This commit is contained in:
@@ -48,9 +48,9 @@ public class GestorMapaMundi {
|
|||||||
Pais paisEncontrado = null;
|
Pais paisEncontrado = null;
|
||||||
|
|
||||||
File ficheroPaises = new File(RUTA_FICHERO);
|
File ficheroPaises = new File(RUTA_FICHERO);
|
||||||
BufferedReader reader = null;
|
|
||||||
try {
|
try (BufferedReader reader = new BufferedReader(new FileReader(ficheroPaises));) {
|
||||||
reader = new BufferedReader(new FileReader(ficheroPaises));
|
|
||||||
while (reader.ready()) {
|
while (reader.ready()) {
|
||||||
String linea = reader.readLine();
|
String linea = reader.readLine();
|
||||||
|
|
||||||
@@ -79,11 +79,6 @@ public class GestorMapaMundi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,9 +89,9 @@ public class GestorMapaMundi {
|
|||||||
List<Pais> listaPaisesEncontrados = null;
|
List<Pais> listaPaisesEncontrados = null;
|
||||||
|
|
||||||
File ficheroPaises = new File(RUTA_FICHERO);
|
File ficheroPaises = new File(RUTA_FICHERO);
|
||||||
BufferedReader reader = null;
|
|
||||||
try {
|
try (BufferedReader reader = new BufferedReader(new FileReader(ficheroPaises));) {
|
||||||
reader = new BufferedReader(new FileReader(ficheroPaises));
|
|
||||||
while (reader.ready()) {
|
while (reader.ready()) {
|
||||||
String linea = reader.readLine();
|
String linea = reader.readLine();
|
||||||
|
|
||||||
@@ -129,11 +124,6 @@ public class GestorMapaMundi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user