Steve
Steve

Reputation: 17

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!

Upvotes: 0

Views: 207

Answers (2)

camickr
camickr

Reputation: 324118

I can type into the JTextArea and save it to a file,

How are you saving the file?

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

Use the textArea.write(...) method to save the file. It will save the file with the proper end of line string for the current platform you are using.

See Text and New Lines for more information.

Upvotes: 1

Mario Rossi
Mario Rossi

Reputation: 7799

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.

Upvotes: 2

Related Questions