How to write an ArrayList of Strings into a text file?

后端 未结 7 1139
不思量自难忘°
不思量自难忘° 2020-11-27 15:47

I want to write an ArrayList into a text file.

The ArrayList is created with the code:

ArrayList arr = new A         


        
7条回答
  •  盖世英雄少女心
    2020-11-27 16:11

    If you need to create each ArrayList item in a single line then you can use this code

    private void createFile(String file, ArrayList arrData)
                throws IOException {
            FileWriter writer = new FileWriter(file + ".txt");
            int size = arrData.size();
            for (int i=0;i

提交回复
热议问题