commit 0c48fcb388982674219df1d9642706b71a064b76 Author: jxu4 Date: Thu Sep 24 16:52:10 2026 +0200 primer commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..4e29ea7 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.project b/.project new file mode 100644 index 0000000..6308568 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Ficheros_02 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..e4acff5 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=26 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=26 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=26 diff --git a/bin/module-info.class b/bin/module-info.class new file mode 100644 index 0000000..34118f3 Binary files /dev/null and b/bin/module-info.class differ diff --git a/bin/org/lapalomafp/aadd/jx/AppPrincipal.class b/bin/org/lapalomafp/aadd/jx/AppPrincipal.class new file mode 100644 index 0000000..6b2a090 Binary files /dev/null and b/bin/org/lapalomafp/aadd/jx/AppPrincipal.class differ diff --git a/bin/org/palomafp/aadd/jx/vo/Continente.class b/bin/org/palomafp/aadd/jx/vo/Continente.class new file mode 100644 index 0000000..27ca34c Binary files /dev/null and b/bin/org/palomafp/aadd/jx/vo/Continente.class differ diff --git a/bin/org/palomafp/aadd/jx/vo/Pais.class b/bin/org/palomafp/aadd/jx/vo/Pais.class new file mode 100644 index 0000000..692f1b3 Binary files /dev/null and b/bin/org/palomafp/aadd/jx/vo/Pais.class differ diff --git a/src/module-info.java b/src/module-info.java new file mode 100644 index 0000000..b9f4f1a --- /dev/null +++ b/src/module-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * + */ +module Ficheros_02 { +} \ No newline at end of file diff --git a/src/org/lapalomafp/aadd/jx/AppPrincipal.java b/src/org/lapalomafp/aadd/jx/AppPrincipal.java new file mode 100644 index 0000000..2464ad9 --- /dev/null +++ b/src/org/lapalomafp/aadd/jx/AppPrincipal.java @@ -0,0 +1,60 @@ +package org.lapalomafp.aadd.jx; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.palomafp.aadd.jx.vo.Continente; +import org.palomafp.aadd.jx.vo.Pais; + +public class AppPrincipal { + + public static void main (String [] args) { + imprimirInformacionPaises (); + + } + + public static void imprimirInformacionPaises() { + File fichero = new File("C:\\Users\\alumnoT\\aadd\\fic02\\informacion_paises.txt"); + + try (BufferedReader leer = new BufferedReader(new FileReader(fichero))) { + String linea; + + // El bucle lee línea a línea mientras no sea null + while ((linea = leer.readLine()) != null) { + linea = linea.trim(); + + // Si está vacía o es un comentario, pasamos a la siguiente + if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("--")) { + continue; + } + + // ¡OJO! Todo esto debe ir DENTRO del while para procesar cada línea válida: + linea = linea.replace("\"", ""); + String[] partes = linea.split(",\\s*"); + + if (partes.length >= 4) { + String codContinente = partes[0]; + int idPais = Integer.parseInt(partes[1]); + String nombrePais = partes[2]; + String capitalPais = partes[3]; + + Continente continente = new Continente(codContinente, null); + Pais pais = new Pais(idPais, nombrePais, capitalPais, continente); + + System.out.println(pais.toString()); + + System.out.println("INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES (" + + pais.getIdentificador() + ", '" + + pais.getContinente().getCodigo() + "', '" + + pais.getCapital() + "', '" + + pais.getNombre() + "');"); + } + } + + } catch (IOException e) { + System.out.println("Error al leer: " + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/org/palomafp/aadd/jx/vo/Continente.java b/src/org/palomafp/aadd/jx/vo/Continente.java new file mode 100644 index 0000000..e3306af --- /dev/null +++ b/src/org/palomafp/aadd/jx/vo/Continente.java @@ -0,0 +1,36 @@ +package org.palomafp.aadd.jx.vo; + +public class Continente { + + private String codigo; + private String nombre; + + public Continente(String codigo, String nombre) { + this.codigo = codigo; + this.nombre = 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/jx/vo/Pais.java b/src/org/palomafp/aadd/jx/vo/Pais.java new file mode 100644 index 0000000..2ee2e0c --- /dev/null +++ b/src/org/palomafp/aadd/jx/vo/Pais.java @@ -0,0 +1,62 @@ +package org.palomafp.aadd.jx.vo; + +public class Pais { + + private int identificador; + private String nombre; + private String capital; + private Continente continente; + + + public Pais(int identificador, String nombre, String capital, Continente continente) { + this.identificador = identificador; + this.nombre = nombre; + this.capital = capital; + this.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() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String toString() { + return "Pais [identificador=" + identificador + ", nombre=" + nombre + ", capital=" + capital + ", continente=" + + continente + "]"; + } + + + + +}