I understand that my question might be repeated, but I couldn't find the answer I need in other question's answer, I have a textArea where some data was appended there. and I want to write that data into a file with the same style of lines as in the textArea My textArea result looks like this
Type Model Serial Country WTY START WTY END SER.STRT SER.END Int.Warrnty
1234 123 1234567 XXXXXX 2012-07-04 2015-07-03 2012-07-04 2015-07-03 Yes
5678 456 4567890 XXXXXX 2011-05-11 2014-06-24 ....-..-.. ....-..-.. No
When I try to write it to a text file it is written there like this after the yes, the second line is written immediately.
Type Model Serial Country WTY START WTY END SER.STRT SER.END Int.Warrnty
1234 123 1234567 XXXXXX 2012-07-04 2015-07-03 2012-07-04 2015-07-03 Yes5678 456 4567890 XXXXXX 2011-05-11 2014-06-24 ....-..-.. ....-..-.. No
I tried to use print stream and file writer and all give the same, I tried as well buffered writer and add new line, still the same problem
my code for this is
String getTextArea_1 = textArea_1.getText();
String userHomeFolder = System.getProperty("user.home");
File file = new File(userHomeFolder, "RESULT_3.txt");
try {
FileWriter fw = new FileWriter(file);
fw.append(getTextArea_1);
fw.flush();
fw.close();
} catch (IOException e1) {
e1.printStackTrace();
}
Thank you for your help