Results 1 to 4 of 4
Thread: New line in FileWriter
- 01-31-2011, 04:03 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
New line in FileWriter
Hi I'm creating a program and a problem appear but its so hard to solve:
here area the problem
I'm taking a string from a JtextArea1 for example:
Java Code:Hi My house is yellow. I have a dog.
and saving in a .txt
Java Code:FileWriter writer; try { writer = new FileWriter("test.txt"); String CA = jTextArea1.getText(); writer.write(CA); writer.close(); } catch (IOException e) { e.printStackTrace(); }
The final result in the .txt is:
Java Code:Hi My house is yellow. I have a dog.
I know I could use "/r/n" or System.getProperty( "line.separator") , however both need be used before the creation the JTextArea,
How I could break the line only changing the code?
Thanks for the help, I hope have been clear
- 01-31-2011, 04:12 AM #2
If you use line breaks to separate the text in the JTextArea then those line breaks should be preserved when you call getText.
- 01-31-2011, 04:41 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
- 01-31-2011, 04:45 AM #4
Similar Threads
-
BufferedWriter, FileWriter
By ladykrimson in forum New To JavaReplies: 4Last Post: 12-06-2010, 02:35 AM -
issue with FileReader and FileWriter
By Uma R in forum Advanced JavaReplies: 6Last Post: 07-16-2010, 01:16 PM -
FileWriter doesn't write
By superman5 in forum NetBeansReplies: 2Last Post: 07-30-2009, 05:46 AM -
JAva Filewriter
By tommyyyy in forum New To JavaReplies: 1Last Post: 03-28-2009, 12:51 PM -
New line or Carriage Return through FileWriter
By johnt in forum New To JavaReplies: 2Last Post: 05-20-2007, 09:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks