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

后端 未结 7 1073
不思量自难忘°
不思量自难忘° 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:22

    You might use ArrayList overloaded method toString()

    String tmp=arr.toString();
    PrintWriter pw=new PrintWriter(new FileOutputStream(file));
    pw.println(tmp.substring(1,tmp.length()-1));
    
    0 讨论(0)
提交回复
热议问题