📜  将arraylist转换为csv文件java代码示例

📅  最后修改于: 2022-03-11 14:52:20.585000             🧑  作者: Mango

代码示例1
import java.util.ArrayList;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;
class test
{
    public static void main(String arg[])throws IOException
    {
        ArrayList list1 = new ArrayList<>();
        list1.add("2212");
        list1.add("gmail.com");

        ArrayList list2 = new ArrayList<>();
        list2.add("192.168.0.175");
        list2.add("403");
        list2.add("192.168.0.26");
        list2.add("1809");

        File file = new File("test.csv");
        FileWriter fw = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(fw);

        bw.write("Domain,Total");
        bw.newLine();
        for(int i=0;i