Here you can find the source of saveStringsList(String file, Collection
public static void saveStringsList(String file, Collection<String> c) throws FileNotFoundException, IOException
//package com.java2s; /*// w ww . j a v a 2 s . co m * Copyright (C) ${year} Omry Yadan <${email}> * All rights reserved. * * See https://github.com/omry/banana/blob/master/BSD-LICENSE for licensing information */ import java.io.*; import java.util.*; public class Main { public static void saveStringsList(String file, Collection<String> c) throws FileNotFoundException, IOException { saveStringsList(file, c, false); } public static void saveStringsList(String file, Collection<String> c, boolean append) throws FileNotFoundException, IOException { File p = new File(file).getParentFile(); if (p != null) p.mkdirs(); FileOutputStream fout = new FileOutputStream(file, append); try { for (String subjectID : c) { fout.write((subjectID + "\n").getBytes()); } } finally { fout.close(); } } }