diff --git a/bin/Ejercicio5/Ejercicio5.class b/bin/Ejercicio5/Ejercicio5.class index 8edc7db..b858d50 100644 Binary files a/bin/Ejercicio5/Ejercicio5.class and b/bin/Ejercicio5/Ejercicio5.class differ diff --git a/src/Ejercicio5/Ejercicio5.java b/src/Ejercicio5/Ejercicio5.java index a1a4f01..42670c8 100644 --- a/src/Ejercicio5/Ejercicio5.java +++ b/src/Ejercicio5/Ejercicio5.java @@ -18,17 +18,23 @@ public class Ejercicio5 { static String escritura; public static void main(String[] args) { - String path = "/home/michael/Documents/SpringProjects/Ejercicio_5/src/Ejercicio5/prueba.txt"; - if (args.length > 0) { - escribirFichero(path); - System.exit(-1); - } + String pathDefault = "/home/michael/Documents/SpringProjects/Ejercicio_5/src/Ejercicio5/prueba.txt"; + String path = null; + File f = null; + + if (args.length > 0) { + path = args[1]; + f = new File(path); + escribirFichero(f); + }else { + f= new File((pathDefault)); + escribirFichero(f); + } } - public static boolean escribirFichero(String path) { - File file = new File(path); + public static boolean escribirFichero(File file) { do { try { @@ -36,7 +42,7 @@ public class Ejercicio5 { pw = new PrintWriter(file); System.out.println("Escribe en el fichero "); - escribirFichero =new FileWriter(path,true); + escribirFichero =new FileWriter(file,true); escritura = usrString.nextLine(); pw.print(escritura);