StatefulBeanToCsv with Column headers

后端 未结 3 1093
长发绾君心
长发绾君心 2021-01-02 04:41

I am using opencsv-4.0 to write a csv file and I need to add column headers in output file.

Here is my code.

public static void buildPro         


        
3条回答
  •  旧巷少年郎
    2021-01-02 05:16

    I may have missed something obvious here but couldn't you just append your header String to the writer object?

    Writer writer = new FileWriter(filePath);
    writer.append("header1, header2, header3, ...etc \n");
    
    // This will be followed by your code with BeanToCsvBuilder 
    // Note: the terminating \n might differ pending env.
    

提交回复
热议问题