I would like to enter a new item into a CSV file but all my items being entered are all staying on one line in the CSV file. I would like each new item to show up on a new line and I can't seem to find the code to make it work. I've tried the \n and that didn't work.
Joined: Oct 13, 2005
You probably don’t need to call flush(); if you look here, you will find out why.
There are methods in the BufferedWriter class which can help with new lines. You are better off buffering your FileWriter with a BufferedWriter. There is an example in the BufferedWriter API. BufferedWriter has a write() method which writes a String, but I think you would do better to put all your Strings together with a StringBuilder, and call its toString() method. That is because you get better performance with fewer calls to access the file. Write one line at a time rather than one word at a time.