commit be69f246ea8d0b334cab3d3d8b093023e80741dd Author: SASI Date: Sun Sep 27 11:19:30 2026 +0200 Primer commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43e6c06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +.settings/ +.classpath +.project \ No newline at end of file diff --git a/src/org/palomafp/aadd/ss/AppPrincipal.java b/src/org/palomafp/aadd/ss/AppPrincipal.java new file mode 100644 index 0000000..6f87227 --- /dev/null +++ b/src/org/palomafp/aadd/ss/AppPrincipal.java @@ -0,0 +1,87 @@ +package org.palomafp.aadd.ss; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +import org.palomafp.aadd.ss.vo.Continente; +import org.palomafp.aadd.ss.vo.Pais; + +public class AppPrincipal { + + public static void main(String[] args) { + + String rutaFichero = "C:\\Users\\sajed\\Desktop\\2DAM\\AADD\\aadd\\fic02\\informacion_paises (1).txt\\"; + File paises = new File(rutaFichero); + + imprimirInformacionPaises(paises); + + } + + public static void imprimirInformacionPaises(File paises) { + + try { + BufferedReader br = new BufferedReader(new FileReader(paises)); + String linea; + + while((linea = br.readLine()) != null) { + + if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("-")) { + continue; + } + linea = linea.replaceAll("\"", ""); + String[] datos = linea.split(","); + + + String codigoContinente = datos[0].trim(); + int identificador = Integer.parseInt(datos[1].trim()); + String nombrePais = datos[2].trim(); + String capital = datos[3].trim(); + + Continente continente = new Continente(); + continente.setCodigo(codigoContinente); + + Pais pais = new Pais(); + pais.setIdentificador(identificador); + pais.setNombre(nombrePais); + pais.setCapital(capital); + pais.setContinente(continente); + + System.out.println(pais); + System.out.println( + "INSERT INTO T_PAIS " + + "(cod_continente, identificador, capital, nombre_pais) " + + "VALUES (" + + pais.getIdentificador() + ", '" + + pais.getContinente().getCodigo() + "', '" + + pais.getCapital() + "', '" + + pais.getNombre() + "');" + ); + + + + } + + br.close(); + + + + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + + + +} diff --git a/src/org/palomafp/aadd/ss/vo/Continente.java b/src/org/palomafp/aadd/ss/vo/Continente.java new file mode 100644 index 0000000..b09697d --- /dev/null +++ b/src/org/palomafp/aadd/ss/vo/Continente.java @@ -0,0 +1,28 @@ +package org.palomafp.aadd.ss.vo; + +public class Continente { + + private String codigo; + private String nombre; + + + public String getCodigo() { + return codigo; + } + public void setCodigo(String codigo) { + this.codigo = codigo; + } + public String getNombre() { + return nombre; + } + public void setNombre(String nombre) { + this.nombre = nombre; + } + @Override + public String toString() { + return "Continente [codigo=" + codigo + ", nombre=" + nombre + "]"; + } + + + +} diff --git a/src/org/palomafp/aadd/ss/vo/Pais.java b/src/org/palomafp/aadd/ss/vo/Pais.java new file mode 100644 index 0000000..07cba39 --- /dev/null +++ b/src/org/palomafp/aadd/ss/vo/Pais.java @@ -0,0 +1,46 @@ +package org.palomafp.aadd.ss.vo; + +public class Pais { + + private int identificador; + private String nombre; + private String capital; + private Continente continente; + + + public int getIdentificador() { + return identificador; + } + public void setIdentificador(int identificador) { + this.identificador = identificador; + } + public String getNombre() { + return nombre; + } + public void setNombre(String nombre) { + this.nombre = nombre; + } + public String getCapital() { + return capital; + } + public void setCapital(String capital) { + this.capital = capital; + } + public Continente getContinente() { + return continente; + } + public void setContinente(Continente continente) { + this.continente = continente; + } + @Override + public String toString() { + return "Pais [identificador=" + identificador + ", nombre=" + nombre + ", capital=" + capital + ", continente=" + + continente + "]"; + } + + + + + + +}