
-----------------------------------
Aziz
Fri Jul 08, 2005 2:39 pm

Serious problem with JTextArea
-----------------------------------
I have a text area...and I get the text from it and write it into a file, but when the text area has a newline in the text area, it writes a weird character (just a box) to the file, and no newline, and when the program reads it again, it doesn't place a newline, just ignores it...Anyhelp? I the program later...

-----------------------------------
rizzix
Fri Jul 08, 2005 2:48 pm


-----------------------------------
yea its the CRLFs & simply LFs issue

where CR represents carriage return and LF stands for line feed...

most unix-like os's and text editors use LFs only, to denote a new line.. ont he othere hand, windows stuff use CRLFs  so you might see wierd characters like those boxes when copy-pasting stuff to and from various applications... as for java i'm not sure but i think its just LFs.. hence those crazy characters, instead of a new line.

-----------------------------------
Aziz
Sat Jul 09, 2005 10:11 am


-----------------------------------
So, how do i get it to show up in my program? Sad

here's the program, btw, source code + classes, and a test file

EDIT: program moved here

EDIT: Okay, SOME progress. instead of using a printwriter's println() method, I used the JTextArea's write() method, and that wrote the actual newlines, but wait, I NOW HAVE AN IDEA....i'll be back.........

EDIT: mother...i just fixed it...so simple, why, why oh so simple??, here's original code used to return a list of chara objects (what stores all the information).


//Get the character records
	private Chara

Now this part here:


//Read description
tempLine = input.readLine();
while (tempLine != null)
{
	tempDesc += tempLine;
	tempLine = input.readLine();
}


Well, as I was writing the last edit to this post, I thought this idea:

[sytnax="java"]tempDesc += tempLine + "\n";[/syntax]

And it worked. It was reading the lines, but not the actual line feed. Thanks for attempting to help, man, but it was a simple thing i completely missed on my part :P

-----------------------------------
rizzix
Sat Jul 09, 2005 1:19 pm


-----------------------------------
right... a simple logic error. *sigh* hehe

-----------------------------------
Aziz
Sat Jul 09, 2005 1:34 pm


-----------------------------------
Those are always the worst ones huh? Happened quite a bit...but thanks. You're such an inspiration for me (that's like the 5th time you've come in handy! :P)
