primer commit
This commit is contained in:
commit
f56a1916bf
10
.classpath
Normal file
10
.classpath
Normal file
@ -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-25">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/bin/
|
||||
*.class
|
||||
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Actividad1_2</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>
|
||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
13
.settings/org.eclipse.jdt.core.prefs
Normal file
13
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=24
|
||||
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=24
|
||||
74
src/es/palomafp/aadd/inm/AppPrincipalFrases.java
Normal file
74
src/es/palomafp/aadd/inm/AppPrincipalFrases.java
Normal file
@ -0,0 +1,74 @@
|
||||
package es.palomafp.aadd.inm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* AppPrincipalPaises: Clase que procesa el fichero de frases.
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 26 sept 2025
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class AppPrincipalFrases {
|
||||
|
||||
public static void main(String[] args) {
|
||||
AppPrincipalFrases app = new AppPrincipalFrases();
|
||||
|
||||
app.procesarFicheroFrases();
|
||||
}
|
||||
|
||||
private void procesarFicheroFrases() {
|
||||
String rutaCarpetaBase = "C:\\Users\\ineva\\aadd\\inm\\act12";
|
||||
String rutaFicheroOriginalFrases = rutaCarpetaBase + "\\frases.txt";
|
||||
File ficheroFrases = new File(rutaFicheroOriginalFrases);
|
||||
|
||||
String rutaCarpetaProcesadas = rutaCarpetaBase + "\\procesadas";
|
||||
File carpetaFrasesProcesadas = new File(rutaCarpetaProcesadas);
|
||||
|
||||
// Crear el directorio la primera vez
|
||||
if (!carpetaFrasesProcesadas.exists()) {
|
||||
carpetaFrasesProcesadas.mkdir();
|
||||
}
|
||||
String rutaFicheroFrasesFiltradas = rutaCarpetaProcesadas + "\\frases_filtradas.txt";
|
||||
|
||||
try (BufferedReader bf = new BufferedReader(new FileReader(ficheroFrases));
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(rutaFicheroFrasesFiltradas))) {
|
||||
String linea;
|
||||
while ((linea = bf.readLine()) != null) {
|
||||
|
||||
// Procesa las líneas que empiecen por '2' o terminen por "Monroe" o "Davis"
|
||||
if (linea.startsWith("2") || linea.endsWith("Monroe") || linea.endsWith("Davis")) {
|
||||
|
||||
// Procesar información de la frase
|
||||
String[] camposFrase = linea.split("\\|");
|
||||
String frase = camposFrase[1].trim();
|
||||
String autor = camposFrase[2].trim();
|
||||
|
||||
String nuevaLinea = frase + " - " + autor;
|
||||
|
||||
// Guardar las frases filtradas
|
||||
System.out.println(linea);
|
||||
bw.write(nuevaLinea);
|
||||
bw.newLine();
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("Fichero no encontrado: " + rutaFicheroOriginalFrases);
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error al leer el fichero: " + rutaFicheroOriginalFrases);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Eliminar fichero
|
||||
ficheroFrases.deleteOnExit();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user