Browse Source

bug eliminados

main
AntonioFrische 1 year ago
parent
commit
2048f3a386
2 changed files with 64 additions and 0 deletions
  1. BIN
      bin/com/antonioFrische/MiCat.class
  2. +64
    -0
      src/com/antonioFrische/MiCat.java

BIN
bin/com/antonioFrische/MiCat.class View File


+ 64
- 0
src/com/antonioFrische/MiCat.java View File

@ -1,7 +1,71 @@
package com.antonioFrische;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class MiCat {
public static final String PATH = "C:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\SpringTool_4\\contents\\sts-4.16.0.RELEASE\\Archnew.txt";
public static void main(String[] args) {
File archivo = new File(PATH);
try{
if(archivo.exists()) {
FileWriter fw = new FileWriter(archivo, true);
writeTo(fw);
fw.flush();
fw.close();
} else {
FileWriter fw=new FileWriter(archivo);
writeTo(fw);
fw.flush();
fw.close();
}
FileReader frResultado = new FileReader(PATH);
BufferedReader brResultado = new BufferedReader(frResultado);
System.out.println("Contenido del fichero:");
System.out.println(brResultado.readLine());
frResultado.close();
brResultado.close();
}catch(IOException e){
System.out.println("Error IOException: "+e);
}
}
public static void writeTo(FileWriter fileWriter) throws IOException {
Scanner reader = new Scanner(System.in);
boolean stop = false;
String introduction;
String slash = "\\";
do {
System.out.println("escribe linia por lina(itiliza el slash para parar):");
introduction = reader.nextLine();
try {
for(int i = 0; i < introduction.length(); i++) {
if(introduction.charAt(i) == slash.charAt(0)) {
stop = true;
break;
} else {
fileWriter.write(introduction.charAt(i));
}
System.out.print(introduction.charAt(i));
}
System.out.print("\n");
} catch(NullPointerException npe) {
}
} while(stop == false);
}
}

Loading…
Cancel
Save