Java tutorial
//package com.java2s; import java.io.*; public class Main { public static boolean byte2file(byte[] bytes, File file) { BufferedOutputStream bos = null; FileOutputStream fos = null; try { fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); bos.write(bytes); return true; } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } finally { try { if (bos != null) bos.close(); if (fos != null) fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }