|
@ -1,7 +1,71 @@ |
|
|
package com.antonioFrische; |
|
|
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 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) { |
|
|
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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |