Copying text in JTextArea to a BufferedWriter
Stupid question, but I can't figure this out.
I'm trying to get the text from a JTextArea printed to a file. The problem is, the text in the JTextArea has newlines ("\n"'s), and they're not displayed in the file whenever I do write(jtextarea.getText()). How can I display these newlines using a buffered writer?
What are you trying to view the file content with? Notepad sometimes has trouble dealing with files that have just \n as the end of line.
You could try filtering your text with
String filtered = raw.replaceAll("\n", "\r\n");
Missed the bus again. Bloody hell - 3 Minutes late!
Message was edited by:
sabre150
The reason I'm sticking with Notepad is because I don't know who'll be using this app, and they'll most likely want to save whatever they're working on in a notepad-friendly file.Anyways, \r\n did the trick.. thanks!