Primer commit
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package org.palomafp.aadd.ss;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.palomafp.aadd.ss.vo.Continente;
|
||||
import org.palomafp.aadd.ss.vo.Pais;
|
||||
|
||||
public class AppPrincipal {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String rutaFichero = "C:\\Users\\sajed\\Desktop\\2DAM\\AADD\\aadd\\fic02\\informacion_paises (1).txt\\";
|
||||
File paises = new File(rutaFichero);
|
||||
|
||||
imprimirInformacionPaises(paises);
|
||||
|
||||
}
|
||||
|
||||
public static void imprimirInformacionPaises(File paises) {
|
||||
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(paises));
|
||||
String linea;
|
||||
|
||||
while((linea = br.readLine()) != null) {
|
||||
|
||||
if (linea.isEmpty() || linea.startsWith("#") || linea.startsWith("-")) {
|
||||
continue;
|
||||
}
|
||||
linea = linea.replaceAll("\"", "");
|
||||
String[] datos = linea.split(",");
|
||||
|
||||
|
||||
String codigoContinente = datos[0].trim();
|
||||
int identificador = Integer.parseInt(datos[1].trim());
|
||||
String nombrePais = datos[2].trim();
|
||||
String capital = datos[3].trim();
|
||||
|
||||
Continente continente = new Continente();
|
||||
continente.setCodigo(codigoContinente);
|
||||
|
||||
Pais pais = new Pais();
|
||||
pais.setIdentificador(identificador);
|
||||
pais.setNombre(nombrePais);
|
||||
pais.setCapital(capital);
|
||||
pais.setContinente(continente);
|
||||
|
||||
System.out.println(pais);
|
||||
System.out.println(
|
||||
"INSERT INTO T_PAIS "
|
||||
+ "(cod_continente, identificador, capital, nombre_pais) "
|
||||
+ "VALUES ("
|
||||
+ pais.getIdentificador() + ", '"
|
||||
+ pais.getContinente().getCodigo() + "', '"
|
||||
+ pais.getCapital() + "', '"
|
||||
+ pais.getNombre() + "');"
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
br.close();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.palomafp.aadd.ss.vo;
|
||||
|
||||
public class Continente {
|
||||
|
||||
private String codigo;
|
||||
private String 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,46 @@
|
||||
package org.palomafp.aadd.ss.vo;
|
||||
|
||||
public class Pais {
|
||||
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String capital;
|
||||
private 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