Here you can find the source of saveFile(List
public static void saveFile(List<String> contents, String fileName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.List; public class Main { public static void saveFile(List<String> contents, String fileName) throws IOException { File file = new File(fileName); saveFile(contents, file);/* w w w. j a v a2 s. co m*/ } public static void saveFile(List<String> contents, File file) throws IOException { FileWriter writer = null; if (file.exists()) { throw new IOException("already exists: " + file.getAbsolutePath()); } try { writer = new FileWriter(file); for (String content : contents) { writer.write(content); writer.write("\r\n"); } } finally { if (writer != null) { writer.close(); } } } }