Here you can find the source of readFileFully(File file)
public static byte[] readFileFully(File file) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; public class Main { private static final int BUFFER_SIZE = 4096; public static byte[] readFileFully(File file) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); FileInputStream inStream = null; try {/*w ww . ja va 2s . com*/ inStream = new FileInputStream(file); int readSize = 0; while ((readSize = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, readSize); } } finally { Arrays.fill(buffer, (byte) 0x00); buffer = null; buffer = outStream.toByteArray(); if (inStream != null) { try { inStream.close(); } catch (IOException e) { //swallow here, just trying to close out } } try { outStream.close(); } catch (IOException e) { //swallow here, just trying to close out } } return buffer; } }