|
|
@ -0,0 +1,30 @@ |
|
|
|
package com.cristobalbernal.Actividad50MiCat; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class Actividad50MiCat { |
|
|
|
private static Scanner lector = new Scanner(System.in); |
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
anadir(); |
|
|
|
} |
|
|
|
public static void anadir(){ |
|
|
|
String ruta = "C:\\Users\\crist\\Documents\\2DAM\\BaseDeDatos\\MiCad.txt"; |
|
|
|
String escrito = ""; |
|
|
|
FileOutputStream file; |
|
|
|
try { |
|
|
|
file = new FileOutputStream(ruta); |
|
|
|
while (!escrito.equalsIgnoreCase("//")){ |
|
|
|
System.out.println("Escribe lo que quieras:"); |
|
|
|
escrito = lector.nextLine(); |
|
|
|
file.write(escrito.getBytes()); |
|
|
|
file.write(("\n").getBytes()); |
|
|
|
} |
|
|
|
file.close(); |
|
|
|
System.out.println("Has decidido salir!!!"); |
|
|
|
} catch (IOException ioi) { |
|
|
|
System.out.println("Error!!!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |