Here you can find the source of writeFile(File file, byte[] data)
public synchronized static void writeFile(File file, byte[] data) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.zip.GZIPOutputStream; public class Main { public synchronized static void writeFile(File filename, String data, boolean gzip) throws IOException { OutputStream outputStream = null; try {/*from w w w .j a v a2s .com*/ outputStream = new FileOutputStream(filename); if (gzip) { outputStream = new GZIPOutputStream(outputStream); } try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"))) { writer.write(data); } } finally { if (outputStream != null) { outputStream.close(); } } } public synchronized static void writeFile(File file, byte[] data) throws IOException { file.mkdirs(); try (FileOutputStream fos = new FileOutputStream(file)) { fos.write(data); } } public synchronized static void writeFile(File filename, String data) throws IOException { writeFile(filename, data, false); } }