Here you can find the source of writeFile(Collection
public static void writeFile(Collection<String> emailTree, String destFile)
//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.Collection; public class Main { public static void writeFile(Collection<String> emailTree, String destFile) { try {//from ww w . j a v a 2 s . c om FileWriter fw = new FileWriter(new File(destFile)); BufferedWriter bw = new BufferedWriter(fw); for (String email : emailTree) { bw.write(email + "\n"); } bw.flush(); bw.close(); } catch (IOException e) { e.printStackTrace(); } } }