Here you can find the source of writeFile(final File destination, final List
public static void writeFile(final File destination, final List<String> contents) throws IOException
//package com.java2s; //License from project: GNU General Public License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.List; public class Main { /** Write the strings to the file, one per line. */ public static void writeFile(final File destination, final List<String> contents) throws IOException { final BufferedWriter bw = new BufferedWriter(new FileWriter(destination)); try {//w w w .j a va 2 s. co m for (String line : contents) { bw.write(line); bw.newLine(); } bw.flush(); } finally { bw.close(); } } }