It is a very simple program, repeat what you write until you put it, and if you tell it to save, save everything you have written in a txt, the problem is that this txt always comes out blank and I do not know why since I have used the same way of saving files more times
import java.io.*;
import java.util.*;
public class Test
{
public static void main(String[] args){
try{
FileWriter fw = new FileWriter("texto.txt");
Scanner teclado = new Scanner(System.in);
String texto = "";
String aux;
System.out.println("Teclee para para parar o guardar para guardar");
do{
aux = teclado.nextLine();
switch(aux){
default:
System.out.println(aux);
texto += aux+"\r\n";
break;
case "guardar":
fw.write(texto);
System.out.println("Guardado");
break;
case "para":
break;
}
}while(!aux.equalsIgnoreCase("para"));
}catch(IOException e){
e.printStackTrace();
}
}
}