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?

[329 byte] By [coprolitoa] at [2007-10-3 1:21:20]
# 1
> and they're not displayed in the fileThose newlines are there alright. Use another editor (vim?) or changethat String so it doesn't just contain \n (newlines) but \r\n (carriage returnsand newlines).kind regards,Jos
JosAHa at 2007-7-14 18:18:33 > top of Java-index,Java Essentials,New To Java...
# 2

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

sabre150a at 2007-7-14 18:18:33 > top of Java-index,Java Essentials,New To Java...
# 3
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!
coprolitoa at 2007-7-14 18:18:33 > top of Java-index,Java Essentials,New To Java...
# 4
> Missed the bus again. Bloody hell - 3 Minutes late!> > Message was edited by: > sabre150'evening Sabre; feeling slow compared to me "speedy Jos" again? ;-)kind regards,Jos ( -> vooom! )
JosAHa at 2007-7-14 18:18:33 > top of Java-index,Java Essentials,New To Java...