Possible Duplicate:
Writing multiline JTextArea content into file
i have written code that save file from my text area the problem is that it saves it all on a single line in the new text file and not as in my text box.below are my codes
String text = dna_ta.getText();
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory( new File( "./") );
int actionDialog = chooser.showSaveDialog(this);
if (actionDialog == JFileChooser.APPROVE_OPTION)
{
BufferedWriter out = null;
try {
File fileName = new File(chooser.getSelectedFile( ) + "" );
if(fileName == null)
return;
if(fileName.exists())
{
actionDialog = JOptionPane.showConfirmDialog(this,
"Replace existing file?");
if (actionDialog == JOptionPane.NO_OPTION)
return;
}
out = new BufferedWriter(new FileWriter(fileName));
out.write(text);
out.close();
in my text area is it as follows
asd
aaaaaa
but in my save textfile it is as follows
asdaaaaaa
i cant figure out where i have gone wrong to save it as same format as in my textarea.thank you