Here you can find the source of getBytesFromFile(File file)
public static byte[] getBytesFromFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] getBytesFromFile(File file) { if (file == null) { return null; } else {/* www . j a v a 2 s . c om*/ FileInputStream stream = null; ByteArrayOutputStream out = null; try { stream = new FileInputStream(file); out = new ByteArrayOutputStream(1000); byte[] b = new byte[1000]; int n; while ((n = stream.read(b)) != -1) { out.write(b, 0, n); } stream.close(); out.close(); byte[] var5 = out.toByteArray(); return var5; } catch (IOException var19) { ; } finally { if (null != stream) { try { stream.close(); } catch (IOException var18) { ; } } if (null != out) { try { out.close(); } catch (IOException var17) { ; } } } return null; } } }