Results 1 to 2 of 2
- 09-18-2011, 02:04 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
Nee help in writing the JTextarea content to a file
Hi,I am having one problem while writing the content of JTextarea to a file.e.g if my textarea contains the following lines:
line1: A
line2: B
line3:\n
line4:\n
if I am writing using "BufferedWriter wr=new BufferedWriter(new FileWriter(file));
wr.write(textarea.getText());" some additional junk characters are added in to the file which can be seen if I open the file in notepad.
The second approach which I used was,if the textarea content I am splitting line by line with the readline() method and writing line by line into the file, such as "BufferedReader reader = new BufferedReader(new StringReader(
textArea.getText()));
out1 = new PrintWriter(file);
while ((l_stSingleLine = reader.readLine()) != null ) {
out1.println(l_stSingleLine);
out1.flush();
}
}"
One extra "\n" is added at last i.e after the write operation file contains five lines(Using the second approach the junk characters are not coming).Please help me in writing the file with exact content.
- 09-18-2011, 05:04 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Nee help in writing the JTextarea content to a file
Cross posted at JTextarea content writing into a file
Similar Threads
-
Writing To A TextFile From A JTextArea
By anthropamorphic in forum AWT / SwingReplies: 13Last Post: 09-11-2011, 03:19 AM -
How to get the content of text file to write in JTextArea?
By realahmed8 in forum New To JavaReplies: 10Last Post: 05-24-2010, 08:25 PM -
Update content on a JTextArea.
By Masochist in forum New To JavaReplies: 7Last Post: 05-13-2010, 10:18 PM -
Im writing to a file and i want to skip lines while writing to a text file.
By Broden_McDonald in forum New To JavaReplies: 1Last Post: 02-27-2010, 01:29 AM -
Jtextarea Content Display Problem
By REVANSIDDHA in forum Advanced JavaReplies: 1Last Post: 03-31-2009, 06:53 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks