|
|
@ -0,0 +1,39 @@ |
|
|
|
package es.antoniotgit; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileWriter; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class MiCat { |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException{ |
|
|
|
|
|
|
|
Scanner lector = new Scanner(System.in); |
|
|
|
|
|
|
|
String path = args[0]; |
|
|
|
|
|
|
|
File fichero = new File(path); |
|
|
|
|
|
|
|
FileWriter fic = new FileWriter(fichero, true); |
|
|
|
|
|
|
|
String fin = "\\"; |
|
|
|
|
|
|
|
System.out.println("Escribe algo"); |
|
|
|
String texto = lector.nextLine(); |
|
|
|
|
|
|
|
for (int i = 0; i < texto.length(); i++) { |
|
|
|
String caracter = String.valueOf(texto.charAt(i)); |
|
|
|
|
|
|
|
if (caracter.equalsIgnoreCase(fin)) { |
|
|
|
fic.close(); |
|
|
|
} else { |
|
|
|
fic.write(caracter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fic.close(); |
|
|
|
} |
|
|
|
|
|
|
|
} |