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.
Re: Nee help in writing the JTextarea content to a file