Search code examples
javaswingfile-ionewlinejtextarea

Writing from JTextArea to File, No Break Lines?


Ok I can type into the JTextArea and save it to a file, however when I open the file in notepad for example it has no breaklines. When loaded back into my program the file has the breaklines again.

I want to know why this happens, whats the point why not just have it the same? and how to make the format be the same when outputting to file so it is the same as it looks in the JTextArea.

In the JTextArea api I do not see any methods that give me any clue on how to do this. Thanks!


Solution

  • Your version of Notepad is most probably not recognizing "unix" end of line sequences (also used/produced by some Java libraries). Try with another text editor. If I remember correctly, Wordpad makes a better job. If not this, you should post code and operating environment.