-
February 3rd, 2012, 08:16 AM
#1
Text Area new line
I'm embarassed since this is my 2nd post today...
Anyways.. I have this text area that holds some lines delimitated by new lines(lines created by pressing enter)
The problem is that when i transfer the text fo a .txt file all the new lines get lost. This results in a pretty big mess...
Any simple abordation for solving this?
BTW: my approach takes the text string as a whole, it doesen't break it down into lines
Thanks:P
-
February 3rd, 2012, 08:53 AM
#2
Re: Text Area new line
I presume you are using a jTextArea? These use the '\n' character for new lines, but this may or may not be the correct line separator for text files on whatever OS you are using. You can change new lines to use the line.separator system property, which will give the correct value for your system.
Just do this before writing your string to file:
Code:
theString.replaceAll("\n", System.getProperty("line.separator"));
-
February 3rd, 2012, 09:03 AM
#3
Re: Text Area new line
do i need to mention that you just saved my day?
thanks a lot
-
February 3rd, 2012, 09:09 AM
#4
Re: Text Area new line
Originally Posted by cens
do i need to mention that you just saved my day?
thanks a lot
Any time It's just one of those silly, annoying things to remember - of which there are far too many
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|