Iam saving JTextArea data in to csv file, but application is not saving the entire data in single cell.
for example: In JTextArea i added data as below
apple
mango
banana
guava
In .csv file it is saving in four rows instead of single row.
below is my code how iam saving the data.
String address ;
address = textArea.getText();
writer.append(address);
writer.append(',');
Can anyone suggest how to fix the issue?
Thanks
Why not replace the newline characters of the JTextArea
with the commas to give you a single CSV row:
writer.append(address.replace("\n", ","));
Output:
apple,mango,banana,guava