Here you can find the source of readFileBytes(String file)
public static byte[] readFileBytes(String file) throws IOException
//package com.java2s; //License from project: Creative Commons License import java.io.*; public class Main { public static byte[] readFileBytes(String file) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedInputStream httpIn = new BufferedInputStream(new FileInputStream(file)); byte[] buffer = new byte[1024]; int n;// ww w. j a v a2 s . c o m while ((n = httpIn.read(buffer)) != -1) baos.write(buffer, 0, n); httpIn.close(); return baos.toByteArray(); } }