Modififaciones
This commit is contained in:
Binary file not shown.
@@ -2,7 +2,6 @@ package org.palomafp.add.aez;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -23,36 +22,33 @@ public class Main {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
reader = new BufferedReader(new FileReader(fichero));
|
reader = new BufferedReader(new FileReader(fichero));
|
||||||
String linea;
|
String linea = null;
|
||||||
|
|
||||||
while ((linea = reader.readLine()) != null) {
|
while ((linea = reader.readLine()) != null) {
|
||||||
linea = linea.trim();
|
linea = linea.trim();
|
||||||
|
|
||||||
if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("--")) {
|
// Estructura según la nueva condición del profesor
|
||||||
continue;
|
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(",");
|
Continente continente = new Continente(codContinente, null);
|
||||||
if (partes.length == 4) {
|
Pais pais = new Pais(identificador, nombrePais, capital, continente);
|
||||||
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);
|
System.out.println(pais);
|
||||||
Pais pais = new Pais(identificador, nombrePais, capital, continente);
|
|
||||||
|
|
||||||
System.out.println(pais);
|
System.out.printf(
|
||||||
|
"INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES ('%s', %d, '%s', '%s');%n",
|
||||||
System.out.printf(
|
pais.getContinente().getCodigo(), pais.getIdentificador(), pais.getCapital(),
|
||||||
"INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES ('%s', %d, '%s', '%s');%n",
|
pais.getNombre());
|
||||||
pais.getContinente().getCodigo(), pais.getIdentificador(), pais.getCapital(),
|
}
|
||||||
pais.getNombre());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@@ -67,4 +63,4 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user