Here you can find the source of readFile(String filename)
static public byte[] readFile(String filename) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { static public byte[] readFile(String filename) throws IOException { File file = new File(filename); long len = file.length(); byte data[] = new byte[(int) len]; FileInputStream fin = new FileInputStream(file); int r = fin.read(data); if (r != len) throw new IOException("Only read " + r + " of " + len + " for " + file);/*w w w.j ava 2 s . c o m*/ fin.close(); return data; } }