commit 262a0b72002952656de0d36649b8af3f75a94c42 Author: SASI Date: Thu Sep 24 15:59:07 2026 +0200 Primer commit. diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..efedf92 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9243f6d --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Ficheros_01 + + + + + + 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..3124684 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=25 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=25 +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.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=25 diff --git a/Actividad1.1.pdf b/Actividad1.1.pdf new file mode 100644 index 0000000..0e64a72 Binary files /dev/null and b/Actividad1.1.pdf differ diff --git a/bin/org/palomafp/aadd/ss/AppPrincipal.class b/bin/org/palomafp/aadd/ss/AppPrincipal.class new file mode 100644 index 0000000..aba3dc5 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/AppPrincipal.class differ diff --git a/src/org/palomafp/aadd/ss/AppPrincipal.java b/src/org/palomafp/aadd/ss/AppPrincipal.java new file mode 100644 index 0000000..a40eef4 --- /dev/null +++ b/src/org/palomafp/aadd/ss/AppPrincipal.java @@ -0,0 +1,51 @@ +package org.palomafp.aadd.ss; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +public class AppPrincipal { + + public static void main(String[] args) { + + String rutaFichero = "C:\\Users\\sajed\\Desktop\\AADD\\aadd\\fic01\\informacion_paises.txt"; + File fichero = new File(rutaFichero); + + if (!fichero.exists()) { + System.err.println("El fichero no existe en la ruta: " + rutaFichero); + return; + } + + // Lectura del fichero utilizando BufferedReader y FileReader + try (BufferedReader br = new BufferedReader(new FileReader(fichero))) { + String linea; + + while ((linea = br.readLine()) != null) { + // Si el fichero viene separado por comas o punto y coma: + // Ejemplo de línea: 02; 65; Colombia; Bogotá + String[] datos = linea.split(";"); // Cambia ';' por ',' si tu archivo usa comas + // System.out.println(datos); + if (datos.length >= 4) { + String codigo = datos[0].trim(); + int prefijo = Integer.parseInt(datos[1].trim()); + String pais = datos[2].trim(); + String capital = datos[3].trim(); + + // Construcción del INSERT con el formato exacto del ejemplo: + // INSERT INTO T_PAIS VALUES ('02',65, 'Colombia', 'Bogotá'); + String sql = String.format( + "INSERT INTO T_PAIS VALUES ('%s', %d, '%s', '%s');", + codigo, prefijo, pais, capital + ); + + System.out.println(sql); + } + } + } catch (IOException e) { + System.err.println("Error al leer el archivo: " + e.getMessage()); + } catch (NumberFormatException e) { + System.err.println("Error al formatear un número: " + e.getMessage()); + } + } +} \ No newline at end of file