Here you can find the source of readBytes(File ff)
public static byte[] readBytes(File ff) throws IOException
//package com.java2s; /*/* ww w.j a v a2 s .c o m*/ * Copyright (C) ${year} Omry Yadan <${email}> * All rights reserved. * * See https://github.com/omry/banana/blob/master/BSD-LICENSE for licensing information */ import java.io.*; public class Main { public static byte[] readBytes(File ff) throws IOException { byte b[] = new byte[(int) ff.length()]; DataInputStream din = new DataInputStream(new FileInputStream(ff)); try { din.readFully(b); } finally { din.close(); } return b; } public static void readFully(InputStream in, byte[] data) throws IOException { int len = data.length; int off = 0; int n = 0; while (n < len) { int count = in.read(data, off + n, len - n); if (count < 0) throw new EOFException(); n += count; } } }