Here you can find the source of write2File(Set
public static void write2File(Set<String> set, String path)
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Set; public class Main { public static void write2File(Set<String> set, String path) { File file = new File(path); try {//from ww w. ja v a 2 s . c o m file.createNewFile(); BufferedWriter bw = new BufferedWriter(new FileWriter(file)); for (String str : set) { bw.write(str); bw.newLine(); } bw.flush(); bw.close(); } catch (IOException e) { e.printStackTrace(); } } }