Here you can find the source of writeFileAsByteArray(File file, byte[] par2Data)
public static void writeFileAsByteArray(File file, byte[] par2Data) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class Main { public static void writeFileAsByteArray(File file, byte[] par2Data) throws IOException { ByteBuffer bb;// w ww . ja v a2 s. co m FileChannel fc = null; try { fc = new FileOutputStream(file).getChannel(); bb = ByteBuffer.wrap(par2Data); fc.write(bb); } finally { if (fc != null) fc.close(); } } }