Here you can find the source of writeBytestoFile(byte[] bytes, String filepath)
public static boolean writeBytestoFile(byte[] bytes, String filepath) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean writeBytestoFile(byte[] bytes, String filepath) throws Exception { boolean ok = true; FileOutputStream fos = null; try {//from w ww. j av a 2 s . co m File f = new File(filepath); if (!f.getParentFile().exists()) { f.getParentFile().mkdirs(); } fos = new FileOutputStream(f); fos.write(bytes); fos.close(); } catch (IOException e) { ok = false; } finally { if (fos != null) fos.close(); } return ok; } }