Here you can find the source of readAllFile(String fileName)
public static byte[] readAllFile(String fileName) throws IOException
//package com.java2s; //License from project: LGPL import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] readAllFile(String fileName) throws IOException { InputStream is = new FileInputStream(fileName); try {//from ww w.j a v a 2 s. com int n = is.available(); byte[] data = new byte[n]; is.read(data); return data; } finally { is.close(); } } }