Here you can find the source of readFileBinaries(File file)
public static byte[] readFileBinaries(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] readFileBinaries(File file) throws IOException { byte[] buffer = new byte[1024]; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); FileInputStream inputStream = new FileInputStream(file); for (int readNum; (readNum = inputStream.read(buffer)) != -1;) { outputStream.write(buffer, 0, readNum); }/*from w w w .j ava 2 s. c o m*/ inputStream.close(); return outputStream.toByteArray(); } }