Primer commit: aadd_fic02
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package org.palomafp.aadd.jaec;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
File fichero = new File("C:\\Users\\alumnoT\\eclipse-workspace\\aadd\\fic02\\informacion_paises.txt");
|
||||
|
||||
String linea = "";
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(fichero))) {
|
||||
while ((linea = br.readLine()) != null) {
|
||||
if (linea.trim().charAt(0) != '#' && !(linea.trim().startsWith("--"))) {
|
||||
imprimirInformacionPaises(linea);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Metodos estaticos
|
||||
public static void imprimirInformacionPaises(String linea) {
|
||||
// Piden mostrar por pantalla
|
||||
// Pais [identificador=93, nombre=Arabia Saudita, capital=Riad,
|
||||
// continente=Continente [codigo=03, nombre=null]] INSERT INTO T_PAIS
|
||||
// (cod_continente, identificador, capital, nombre_pais) VALUES (93, '03',
|
||||
// 'Riad', 'Arabia Saudita');
|
||||
|
||||
// Ejemplo de la estructura de una linea de texto
|
||||
// "03",93, "Arabia Saudita", "Riad"
|
||||
|
||||
String[] informacion = linea.split(",");
|
||||
String codContinente = informacion[0].replace("\"", "").trim();
|
||||
String idPais = informacion[1].trim();
|
||||
String nombrePais = informacion[2].replace("\"", "").trim();
|
||||
String capitalPais = informacion[3].replace("\"", "").trim();
|
||||
|
||||
System.out.println("Pais [identificador=" + idPais + ", nombre=" + nombrePais + ", capital=" + capitalPais
|
||||
+ ", continente=Continente [codigo=" + codContinente + ", nombre=null]] "
|
||||
+ "INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES (" + idPais + ", '"
|
||||
+ codContinente + "', '" + capitalPais + "', '" + nombrePais + "');");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.palomafp.aadd.jaec.vo;
|
||||
|
||||
public class Continente {
|
||||
private String codigo, nombre;
|
||||
|
||||
public Continente() {
|
||||
// Constructor vacio
|
||||
}
|
||||
|
||||
public Continente(String codigo, String nombre) {
|
||||
this.codigo = codigo;
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
// Getters y Setters
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.palomafp.aadd.jaec.vo;
|
||||
|
||||
public class Pais {
|
||||
private int identificador;
|
||||
private String nombre, capital;
|
||||
private Continente continente;
|
||||
|
||||
public Pais() {
|
||||
// Constructor vacio
|
||||
}
|
||||
|
||||
public Pais(int identificador, String nombre, String capital, Continente continente) {
|
||||
this.identificador = identificador;
|
||||
this.nombre = nombre;
|
||||
this.capital = capital;
|
||||
this.continente = continente;
|
||||
}
|
||||
|
||||
|
||||
// Getters y Setters
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user