Create CSV file in Java

Create CSV file in Java

—CreateCSV.java—

import java.io.FileWriter;
import java.io.IOException;

public class CreateCSV {

    public static void main(String[] args) {
        // TODO code application logic here
        try
        {
FileWriter writer=new FileWriter("D:\\csv\\codedbug.csv");
            for(int i=1;i<=10;i++)
            {
                writer.append("CSV"+i);
                writer.append('\n');
            }
            writer.flush();
	    writer.close();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }
}