Here you can find the source of readFileBinary(String filename)
public static byte[] readFileBinary(String filename) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static byte[] readFileBinary(String filename) throws IOException { File file = new File(filename); byte[] data = new byte[(int) file.length()]; DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); dis.readFully(data);//from w ww. ja v a 2s . c om dis.close(); return data; } }