JAva.

Thread Starter

gusmas

Joined Sep 27, 2008
239
i need to write from a jtextarea to a text file, but i have no idea how i am going to di it, any ideas
 

davebee

Joined Oct 22, 2008
540
A JTextArea inherits the method "String getText()" from JTextComponent, so can you open a file, do

String mytext = myJTextArea.getText();

then write that string to the file, like

out.write(mytext);
 

Thread Starter

gusmas

Joined Sep 27, 2008
239
Cool thx that worked, bt when i make a couple of lines beneath one another in the jtextfield, it saves all the text next to each other and the new liner have a funny symbol
 

davebee

Joined Oct 22, 2008
540
The JTextArea is fairly simple in its formatting. It will break text for display on word boundaries, but it does not embed CR/LF characters into the text.

So on extracting the text, you get exactly what had been initially written in.

If you want line formatting from a JTextArea object, you'll have to do it yourself somehow.
 
Top