Here you can find the source of readFile(File file)
public static byte[] readFile(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] readFile(File file) throws IOException { byte[] data = null; FileInputStream fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int br;/*w ww . j av a 2 s . com*/ while ((br = bis.read(buffer)) > 0) { baos.write(buffer, 0, br); } baos.close(); bis.close(); data = baos.toByteArray(); return data; } }