Primer commit actividad 1.1
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user