I want the String text
to be saved as a .txt file wherever I want. I think you can do that by using JFileChooser. Anyway here is my Code:
class TextEditorFrame extends JFrame {
JFileChooser chooser;
public TextEditorFrame(){
Scanner s = new Scanner(System.in);
chooser = new JFileChooser();
String text = s.nextLine();
try (PrintStream out = new PrintStream(new FileOutputStream("filename.txt"))){
out.print(text);
System.out.println("Text Saved:");
System.out.println(text);
} catch (FileNotFoundException ex) {
System.out.println("Something went wrong...");
}
}
}
This is my code so far. Any way I can combine the JFileChooser with the String text?
NOTE: This is not the full code but everything you need to know is in here.