diff --git a/bin/org/palomafp/add/aez/Main.class b/bin/org/palomafp/add/aez/Main.class index fbdd5fe..eec22a5 100644 Binary files a/bin/org/palomafp/add/aez/Main.class and b/bin/org/palomafp/add/aez/Main.class differ diff --git a/src/org/palomafp/add/aez/Main.java b/src/org/palomafp/add/aez/Main.java index 5faa06c..07729cd 100644 --- a/src/org/palomafp/add/aez/Main.java +++ b/src/org/palomafp/add/aez/Main.java @@ -2,7 +2,6 @@ package org.palomafp.add.aez; import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -23,36 +22,33 @@ public class Main { try { reader = new BufferedReader(new FileReader(fichero)); - String linea; + String linea = null; while ((linea = reader.readLine()) != null) { linea = linea.trim(); - if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("--")) { - continue; - } + // Estructura según la nueva condición del profesor + if (!linea.isEmpty() && !(linea.startsWith("#") || linea.startsWith("--"))) { + String[] partes = linea.split(","); + if (partes.length == 4) { + String codContinente = partes[0].replace("\"", "").trim(); + int identificador = Integer.parseInt(partes[1].trim()); + String nombrePais = partes[2].replace("\"", "").trim(); + String capital = partes[3].replace("\"", "").trim(); - String[] partes = linea.split(","); - if (partes.length == 4) { - String codContinente = partes[0].replace("\"", "").trim(); - int identificador = Integer.parseInt(partes[1].trim()); - String nombrePais = partes[2].replace("\"", "").trim(); - String capital = partes[3].replace("\"", "").trim(); + Continente continente = new Continente(codContinente, null); + Pais pais = new Pais(identificador, nombrePais, capital, continente); - Continente continente = new Continente(codContinente, null); - Pais pais = new Pais(identificador, nombrePais, capital, continente); + System.out.println(pais); - System.out.println(pais); - - System.out.printf( - "INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES ('%s', %d, '%s', '%s');%n", - pais.getContinente().getCodigo(), pais.getIdentificador(), pais.getCapital(), - pais.getNombre()); + System.out.printf( + "INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES ('%s', %d, '%s', '%s');%n", + pais.getContinente().getCodigo(), pais.getIdentificador(), pais.getCapital(), + pais.getNombre()); + } } } - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NumberFormatException e) { @@ -67,4 +63,4 @@ public class Main { } } } -} +} \ No newline at end of file