Here you can find the source of copyBytesToFile(byte[] bytes, File outputFile)
public static File copyBytesToFile(byte[] bytes, File outputFile) throws Exception
//package com.java2s; /**// ww w . j a v a 2 s . c om * License: https://github.com/votingsystem/votingsystem/wiki/Licencia */ import java.io.*; public class Main { private static final int BUFFER_SIZE = 4096; public static File copyBytesToFile(byte[] bytes, File outputFile) throws Exception { InputStream inputStream = new ByteArrayInputStream(bytes); OutputStream outputStream = new FileOutputStream(outputFile); byte[] buf = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } outputStream.close(); inputStream.close(); return outputFile; } }