Here you can find the source of writeFile(String fileName, byte[] bytes)
public static void writeFile(String fileName, byte[] bytes) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { public static void writeFile(String fileName, byte[] bytes) throws IOException { File f = new File(fileName); if (!f.exists()) { f.createNewFile();/*from ww w . j a v a 2 s .co m*/ } else { f.delete(); f.createNewFile(); } OutputStream os = new FileOutputStream(f); BufferedOutputStream out = new BufferedOutputStream(os); out.write(bytes); out.close(); os.close(); f = null; } }