Here you can find the source of saveList(String listName, Set
public static void saveList(String listName, Set<String> list) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.Set; public class Main { public static void saveList(String listName, Set<String> list) throws FileNotFoundException, IOException { try (BufferedWriter bw = new BufferedWriter(new FileWriter( new File(listName)))) { for (String line : list) { bw.write(line);/* ww w . ja v a 2 s . com*/ bw.write("\n"); } } } }