Primer commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -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
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
-- Información de Paises
|
||||
# Se muestra información del código de continente, identificador de país, nombrel del país junto con su capital
|
||||
"01",1, "Angola", "Luanda"
|
||||
"02",62, "Brasil", "Brasilia"
|
||||
"02",63, "Canadá", "Ottawa"
|
||||
"02",64, "Chile", "Santiago De Chile"
|
||||
"02",65, "Colombia", "Bogotá"
|
||||
"03",92, "Afganistán", "Kabul"
|
||||
"03",93, "Arabia Saudita", "Riad"
|
||||
"03",105, "Filipinas", "Manila"
|
||||
"03",106, "India", "Nueva Delhi"
|
||||
"03",136, "Vietnam", "Hanoi"
|
||||
"04",147, "Bulgaria", "Sofía"
|
||||
"04",152, "España", "Madrid"
|
||||
"04",181, "Suecia", "Estocolmo"
|
||||
"04",182, "Suiza", "Berna"
|
||||
"05",185, "Australia", "Canberra"
|
||||
"05",186, "Fiyi", "Suva"
|
||||
"05",187, "Islas Marshall", "Majuro"
|
||||
"05",196, "Tonga", "Nuku'alofa"
|
||||
"05",197, "Tuvalu", "Funafuti"
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.palomafp.aadd.npz;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.palomafp.aadd.npz.vo.Continente;
|
||||
import org.palomafp.aadd.npz.vo.Pais;
|
||||
|
||||
public class Main {
|
||||
|
||||
private final static String nombreArchivo = "C:\\Users\\npauc\\aadd\\fic02\\informacion_paises.txt";
|
||||
|
||||
public static void main(String[] args) {
|
||||
imprimirInformacionPaises();
|
||||
}
|
||||
|
||||
public static void imprimirInformacionPaises() {
|
||||
|
||||
File f = new File(nombreArchivo);
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(f))){
|
||||
String linea;
|
||||
while((linea = br.readLine()) != null) {
|
||||
linea = linea.trim(); //limpia espacios dentro del archivo con trim
|
||||
if(!linea.isEmpty() && !linea.startsWith("#") && !linea.startsWith("--")) {
|
||||
String infoDatos[] = linea.replace("\"", "").split(",");
|
||||
|
||||
String codigoContinente = infoDatos[0].trim();
|
||||
String idPais = infoDatos[1].trim();
|
||||
String nombrePais = infoDatos[2].trim();
|
||||
String capitalPais = infoDatos[3].trim();
|
||||
|
||||
Continente continente = new Continente();
|
||||
continente.setCodigo(codigoContinente);
|
||||
|
||||
Pais pais = new Pais();
|
||||
pais.setIdentificador(Integer.parseInt(idPais));
|
||||
pais.setNombre(nombrePais);
|
||||
pais.setCapital(capitalPais);
|
||||
pais.setContinente(continente);
|
||||
|
||||
System.out.println(pais);
|
||||
|
||||
String sentenciaSQL = String.format("INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) "
|
||||
+ "VALUES (%d,'%s' '%s', '%s');", pais.getIdentificador(), pais.getContinente().getCodigo(), pais.getCapital(), pais.getNombre());
|
||||
System.out.println(sentenciaSQL);
|
||||
}
|
||||
}
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.palomafp.aadd.npz.vo;
|
||||
|
||||
public class Continente{
|
||||
private String codigo;
|
||||
private String nombre;
|
||||
public Continente() {}
|
||||
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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.palomafp.aadd.npz.vo;
|
||||
|
||||
public class Pais {
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String capital;
|
||||
private Continente continente;
|
||||
|
||||
public Pais () {}
|
||||
|
||||
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() {
|
||||
return continente;
|
||||
}
|
||||
|
||||
public void setContinente(Continente continente) {
|
||||
this.continente = continente;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pais [identificador=" + identificador + ", nombre=" + nombre
|
||||
+ ", capital=" + capital + "continente=" + continente + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user