Here you can find the source of writeFile(OutputStream file, List
public static void writeFile(OutputStream file, List<String> data)
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.util.List; public class Main { private static final String S_NEWLINE = System.getProperty("line.separator"); public static void writeFile(OutputStream file, List<String> data) { BufferedWriter bufferedWriter = null; try {// w ww .j a v a 2 s . com bufferedWriter = new BufferedWriter(new OutputStreamWriter(file, Charset.defaultCharset())); for (String line : data) { bufferedWriter.write(line); bufferedWriter.write(S_NEWLINE); } } catch (Exception e) { throw new RuntimeException(e); } finally { try { if (bufferedWriter != null) { bufferedWriter.flush(); bufferedWriter.close(); } } catch (Exception e) { throw new RuntimeException(e); } } } }