Here you can find the source of writeFile(File file, byte[] data)
public static void writeFile(File file, byte[] data) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void writeFile(File file, byte[] data) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(data); FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos); byte[] buffer = new byte[1024]; int br;/* w w w . j av a 2 s . c om*/ while ((br = bais.read(buffer)) > 0) { bos.write(buffer, 0, br); } bos.close(); bais.close(); } }