Primer commit actividad 1.2
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
# Compilados de Java
|
||||||
|
*.class
|
||||||
|
bin/
|
||||||
|
|
||||||
|
# Configuración de Eclipse
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.palomafp.add.smmb;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.palomafp.add.smmb.vo.Continente;
|
||||||
|
import org.palomafp.add.smmb.vo.Pais;
|
||||||
|
|
||||||
|
public class Fic02 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
File paises = new File("D:/Documentos/DAM 2/AC - Acceso a Datos/Practicas/aadd/fic02/informacion_paises.txt");
|
||||||
|
|
||||||
|
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("-"))){
|
||||||
|
|
||||||
|
String[] campos = linea.split(",");
|
||||||
|
|
||||||
|
|
||||||
|
String codContinente = campos[0].trim().replace("\"", "");
|
||||||
|
int id = Integer.parseInt(campos[1].trim());
|
||||||
|
String nombre = campos[2].trim().replace("\"", "");
|
||||||
|
String capital = campos[3].trim().replace("\"", "");
|
||||||
|
|
||||||
|
|
||||||
|
Continente continente = new Continente(codContinente);
|
||||||
|
Pais pais = new Pais(id, nombre, capital, continente);
|
||||||
|
|
||||||
|
System.out.println(pais);
|
||||||
|
System.out.println("INSERT INTO T_PAIS VALUES (" + continente + ", " + id + ", " + nombre + ", " + capital + ");");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
System.out.println(ioe.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.palomafp.add.smmb.vo;
|
||||||
|
|
||||||
|
public class Continente {
|
||||||
|
|
||||||
|
private String codigo;
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
public Continente(String codigo, String nombre) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Continente(String codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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.add.smmb.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) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Pais [identificador=" + identificador + ", nombre=" + nombre + ", capital=" + capital + ", continente="
|
||||||
|
+ continente + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user