Here you can find the source of getFileContent(final File f)
public static byte[] getFileContent(final File f) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; public class Main { public static byte[] getFileContent(final File f) throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final BufferedInputStream in = new BufferedInputStream( new FileInputStream(f)); final byte[] buffer = new byte[40960]; while (in.available() > 0) { final int s = in.read(buffer); out.write(buffer, 0, s);/*from w w w . j a v a2 s .com*/ } // dispose all the resources after using them. in.close(); return out.toByteArray(); } }