Here you can find the source of writeBytesToFile(File file, byte[] bytes)
public static void writeBytesToFile(File file, byte[] bytes)
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void writeBytesToFile(File file, byte[] bytes) { file.getParentFile().mkdirs();/*from w ww. jav a 2 s . c o m*/ try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) { out.write(bytes); out.flush(); } catch (IOException e) { throw new RuntimeException("Failed to write file: " + file.getPath()); } } }