segundo
This commit is contained in:
+10
@@ -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_01</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.
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
module Actividad1_Jilai {
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package org.palomafp.aadd.jx; // Reemplaza 'xxx' por tus iniciales
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class AppPrincipal {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
// Colocaremos la ruta que tengamos, en mi caso la cuenta de usuario es alumnoT
|
||||||
|
|
||||||
|
String rutaCarpeta = "C:\\Users\\alumnoT\\aadd\\fic01\\";
|
||||||
|
String nombreFichero = "informacion_paises.txt";
|
||||||
|
File fichero = new File(rutaCarpeta + nombreFichero);
|
||||||
|
|
||||||
|
|
||||||
|
BufferedReader bufferLectura = null;
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Comprobamos si existe el fichero
|
||||||
|
if (!fichero.exists()) {
|
||||||
|
System.out.println("No se encuentra el fichero en la ruta: " + fichero.getAbsolutePath());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializamos la lectura y se guardara en un buffer
|
||||||
|
|
||||||
|
bufferLectura = new BufferedReader(new FileReader(fichero));
|
||||||
|
String linea;
|
||||||
|
|
||||||
|
System.out.println("--- INICIO ---");
|
||||||
|
|
||||||
|
// vAmos a recorrer el fichero paso a paso
|
||||||
|
while ((linea = bufferLectura.readLine()) != null) {
|
||||||
|
|
||||||
|
// Filtramos únicamente la línea que queramos por ejemplo que empiece por #
|
||||||
|
if (linea.trim().startsWith("#") || linea.trim().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vamos a seperar con comas para que se entiendan las cosas
|
||||||
|
String[] campos = linea.split(",");
|
||||||
|
|
||||||
|
if (campos.length >= 4) {
|
||||||
|
|
||||||
|
// Ejemplo de limpieza de comillas si el formato de los campos las incluye
|
||||||
|
String idCiclo = campos[0].replace("\"", "").trim();
|
||||||
|
String nombreCiclo = campos[2].replace("\"", "").trim();
|
||||||
|
|
||||||
|
int anio = 2000;
|
||||||
|
String familia = (idCiclo.length() >= 3) ? idCiclo.substring(0, 3) : idCiclo;
|
||||||
|
|
||||||
|
// Imprimimos por consola el literal requerido por la actividad
|
||||||
|
System.out.println("INSERT INTO T_PAIS VALUES ('" + idCiclo + "', '" + nombreCiclo + "', " + anio + ", '" + familia + "');");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("--- FIN ---");
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Error de E/S al leer el fichero: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (bufferLectura != null) {
|
||||||
|
bufferLectura.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Error al cerrar el fichero: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user