Here you can find the source of readAll(File file)
public static byte[] readAll(File file) throws IOException
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static byte[] readAll(File file) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(new BufferedInputStream(new FileInputStream(file)), baos); return baos.toByteArray(); }// w ww .j ava 2s .c o m public static void copy(InputStream is, OutputStream os) throws IOException { try { byte[] buf = new byte[10240]; int len; while ((len = is.read(buf)) != -1) { os.write(buf, 0, len); } } finally { os.close(); is.close(); } } }