Primer commit actividad 1.1

This commit is contained in:
sheila-mb28
2026-09-22 17:44:09 +02:00
commit ef2cde3343
7 changed files with 92 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package org.palomafp.aadd.smmb;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class Fic01 {
public static void main(String[] args) {
File paises = new File("D:/Documentos/DAM 2/AC - Acceso a Datos/Practicas/aadd/fic01/informacion_paises.txt");
try {
BufferedReader br = new BufferedReader(new FileReader(paises));
String linea = "";
while((linea = br.readLine()) != null) {
if (!(linea.isEmpty() || linea.startsWith("#"))){
String[] campos = linea.split(",");
String continente = campos[0].trim().replace("\"", "\'");
String id = campos[1].trim();
String nombre = campos[2].trim().replace("\"", "\'");
String capital = campos[3].trim().replace("\"", "\'");
System.out.println("INSERT INTO T_PAIS VALUES (" + continente + "," + id + "," + nombre + "," + capital + ");");
}
}
br.close();
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}