有没有办法通过使用“ |”将<string>的ArrayList写入csv文件中作为分隔符?

时间:2019-04-18 11:54:16

标签: java string csv arraylist

我在List内有一堆ArrayList对象。

我需要将所有ArrayList对象写入带有管道“ |”的csv文件中分隔符。

        String filePath = "C:\\Users\\test2.csv";
        FileWriter outputfile = new FileWriter(file);

        CSVWriter writer = new CSVWriter(outputfile, '|',
                CSVWriter.NO_QUOTE_CHARACTER,
                CSVWriter.DEFAULT_ESCAPE_CHARACTER,
                CSVWriter.DEFAULT_LINE_END);



        List<ArrayList<String>> databaseColListToFetch=databaseColList;
        for(int i=0;i<databaseColList.size();i++){
            ArrayList<String> al=databaseColList.get(i);
            //Need code here which will write all the ArrayList Objects into csv file
            //writer.writeAll(al);//not sure about csv writer will write ArrayList<String> 

        }
        writer.close();

0 个答案:

没有答案