Here you can find the source of writeFile(List
public static void writeFile(List<String> strList, String fileFullPath)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.List; public class Main { /**/* ww w.ja v a2s . c o m*/ * LINE_SEPARATOR<br/> * windows:\r\n */ public static final String LINE_SEPARATOR = System.getProperty("line.separator"); public static void writeFile(List<String> strList, String fileFullPath) { try { File writeFile = new File(fileFullPath); new File(writeFile.getParent()).mkdirs(); writeFile.createNewFile(); BufferedWriter out = new BufferedWriter(new FileWriter(writeFile)); for (String str : strList) { out.write(str + LINE_SEPARATOR); } out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } }