Here you can find the source of saveListToFile(ArrayList
public static void saveListToFile(ArrayList<String> list, String filePath)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; public class Main { public static void saveListToFile(ArrayList<String> list, String filePath) {/* w w w . ja va 2 s . c om*/ File file = new File(filePath); try { FileWriter fw = new FileWriter(file); for (int i = 0; i < list.size(); i++) { String s = list.get(i); fw.write(s + "\n"); System.out.println(s); } fw.close(); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } }