Here you can find the source of getBytesFromFile(String file)
public static byte[] getBytesFromFile(String file) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; public class Main { public static byte[] getBytesFromFile(String file) throws Exception { byte[] res = null; try {//from www.j a v a 2 s . c o m File f = new File(file); FileInputStream fin = new FileInputStream(f); res = new byte[fin.available()]; int b = fin.read(res); if (b != res.length) { return null; } fin.close(); return res; } catch (Exception e) { e.printStackTrace(); } return null; } }