Primer commit.

This commit is contained in:
SASI
2026-09-24 15:59:07 +02:00
commit 262a0b7200
7 changed files with 91 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Ficheros_01</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
+11
View File
@@ -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
BIN
View File
Binary file not shown.
Binary file not shown.
@@ -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());
}
}
}