Here you can find the source of writeFile(OutputStream output, String text)
public static boolean writeFile(OutputStream output, String text)
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; public class Main { public static boolean writeFile(File out, String text) { try {/*from w w w . ja v a 2 s . c o m*/ return writeFile(new FileOutputStream(out), text); } catch (Exception e) { e.printStackTrace(); return false; } } public static boolean writeFile(OutputStream output, String text) { OutputStreamWriter out = null; BufferedWriter buffer = null; try { out = new OutputStreamWriter(output); buffer = new BufferedWriter(out); buffer.write(text); } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (buffer != null) buffer.close(); if (out != null) out.close(); if (output != null) output.close(); } catch (Exception e) { } } return true; } }