Here you can find the source of readFile(String filename)
public static byte[] readFile(String filename) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static byte[] readFile(String filename) throws IOException { FileInputStream fis = new FileInputStream(filename); try {/*w ww. j a v a 2s. c o m*/ return getByteArrayFromStream(fis); } finally { fis.close(); } } public static byte[] getByteArrayFromStream(InputStream is) throws IOException { byte[] b = new byte[10000]; int read; ByteArrayOutputStream out = new ByteArrayOutputStream(); while ((read = is.read(b, 0, b.length)) > 0) { out.write(b, 0, read); } return out.toByteArray(); } }