Here you can find the source of readFile(String filepath)
@SuppressWarnings("resource") public static byte[] readFile(String filepath)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; public class Main { @SuppressWarnings("resource") public static byte[] readFile(String filepath) { byte[] result = null; try {/* www.j av a 2 s . co m*/ File file = new File(filepath); if (file.length() <= Integer.MAX_VALUE) { result = new byte[(int) file.length()]; RandomAccessFile raf = new RandomAccessFile(file, "r"); raf.readFully(result); } } catch (FileNotFoundException e) { //e.printStackTrace(); } catch (IOException e) { //e.printStackTrace(); } return result; } }