Here you can find the source of readBytes(String filename)
private static byte[] readBytes(String filename) throws IOException
//package com.java2s; //License from project: LGPL import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { private static byte[] readBytes(String filename) throws IOException { File file = new File(filename); FileInputStream fileInputStream = new FileInputStream(file); DataInputStream dataInputStream = new DataInputStream(fileInputStream); try {// ww w .ja va2 s .c om byte[] keyBytes = new byte[(int) file.length()]; dataInputStream.readFully(keyBytes); return keyBytes; } finally { dataInputStream.close(); } } }