ejercicio2
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.palomafp.aadd.rces;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.palomafp.aadd.rces.vo.Continente;
|
||||
import org.palomafp.aadd.rces.vo.Pais;
|
||||
|
||||
public class AppPrincipal {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
imprimirInformacionPaises();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void imprimirInformacionPaises() {
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\ricardo\\aadd\\fic01\\informacion_paises.txt"));
|
||||
String linea;
|
||||
while((linea = br.readLine()) != null) {
|
||||
if(!linea.startsWith("#") && !linea.startsWith("--")) {
|
||||
String infoDatos[] = linea.replace("\"","'").split(",");
|
||||
|
||||
Continente continente = new Continente(infoDatos[0],null);
|
||||
Pais pais = new Pais( Integer.parseInt(infoDatos[1]),infoDatos[2],infoDatos[3],continente);
|
||||
System.out.println(pais.toString());
|
||||
System.out.println();
|
||||
System.out.println("INSERT INTO T_PAIS (cod_continente, identificador, capital,\r\n"
|
||||
+ "nombre_pais)"+"Values("+continente.getCodigo()+","+pais.getIdentificador()+","+pais.getNombre()+","+pais.getCapital()+")");
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.palomafp.aadd.rces.vo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Continente {
|
||||
private String codigo;
|
||||
private String nombre;
|
||||
|
||||
public Continente(String codigo, String nombre) {
|
||||
super();
|
||||
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=" + codigo + ", nombre=" + nombre + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.palomafp.aadd.rces.vo;
|
||||
|
||||
public class Pais {
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String capital;
|
||||
private Continente continente;
|
||||
|
||||
|
||||
public Pais(int identificador, String nombre, String capital, Continente continente) {
|
||||
super();
|
||||
this.identificador = identificador;
|
||||
this.nombre = nombre;
|
||||
this.capital = capital;
|
||||
this.continente = continente;
|
||||
}
|
||||
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