primer commit
This commit is contained in:
@@ -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/jdk-27">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Fichero_02</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
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=26
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=26
|
||||||
|
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.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=26
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
module Fichero_02 {
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package org.palomafp.aadd.lmga;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.palomafp.aadd.lmga.vo.*;
|
||||||
|
|
||||||
|
public class AppPrincipal {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String fichero = "C:\\Users\\alumnoT\\aadd\\fic02\\informacion_paises.txt";
|
||||||
|
imprimirInformacionPaises(fichero);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void imprimirInformacionPaises(String ruta){
|
||||||
|
File archivo = new File(ruta);
|
||||||
|
try(BufferedReader br = new BufferedReader(new FileReader(archivo))){
|
||||||
|
String linea;
|
||||||
|
|
||||||
|
while ((linea = br.readLine()) != null) {
|
||||||
|
linea = linea.trim();
|
||||||
|
|
||||||
|
|
||||||
|
if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("--")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String[] campos = linea.split(",");
|
||||||
|
|
||||||
|
if (campos.length >= 4) {
|
||||||
|
|
||||||
|
String codContinente = campos[0].replace("\"", "").trim();
|
||||||
|
int id = Integer.parseInt(campos[1].replace("\"", "").trim());
|
||||||
|
String nombre = campos[2].replace("\"", "").trim();
|
||||||
|
String capital = campos[3].replace("\"", "").trim();
|
||||||
|
|
||||||
|
Continente continente = new Continente(codContinente, null);
|
||||||
|
Pais pais = new Pais(id, nombre, capital, continente);
|
||||||
|
|
||||||
|
String sql = String.format("INSERT INTO T_PAIS(cod_continente, identificador, capital, nombre_pais) VALUES ('%s', '%d', '%s', '%s';);",
|
||||||
|
pais.getContinente().getCodigo(),
|
||||||
|
pais.getIdentificador(),
|
||||||
|
pais.getCapital(),
|
||||||
|
pais.getNombre());
|
||||||
|
|
||||||
|
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 valor numérico: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.palomafp.aadd.lmga.vo;
|
||||||
|
|
||||||
|
public class Continente {
|
||||||
|
|
||||||
|
private String codigo, nombre;
|
||||||
|
|
||||||
|
public Continente() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Continente(String codigo, String nombre) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
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=" + this.codigo + ", nombre=" + this.nombre + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.palomafp.aadd.lmga.vo;
|
||||||
|
|
||||||
|
public class Pais {
|
||||||
|
|
||||||
|
private String nombre, capital;
|
||||||
|
private int identificador;
|
||||||
|
private Continente continente;
|
||||||
|
public Pais() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pais(int identificador, String nombre, String capital, Continente continente) {
|
||||||
|
this.identificador = identificador;
|
||||||
|
this.nombre = nombre;
|
||||||
|
this.capital = capital;
|
||||||
|
this.continente = continente;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 int getIdentificador() {
|
||||||
|
return identificador;
|
||||||
|
}
|
||||||
|
public void setIdentificador(int identificador) {
|
||||||
|
this.identificador = identificador;
|
||||||
|
}
|
||||||
|
public Continente getContinente() {
|
||||||
|
return continente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContinente(Continente continente) {
|
||||||
|
this.continente = continente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "Pais [identificador=" + this.identificador + ", nombre=" + this.nombre + ", capital=" + this.capital + ", continente=";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
Reference in New Issue
Block a user