Here you can find the source of readFile(File f)
static private byte[] readFile(File f)
//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; import java.io.IOException; public class Main { /** Utility method for reading a file, used for testing. */ static private byte[] readFile(File f) { // Get the content as a byte array, and compute its checksum byte[] content = new byte[0]; try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); ByteArrayOutputStream out = new ByteArrayOutputStream()) { // Get a chunk at a time byte[] buffer = new byte[8192]; // 8K int bytesRead; while ((bytesRead = in.read(buffer)) > 0) { out.write(buffer, 0, bytesRead); }//from w ww. j a v a 2 s . co m content = out.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return content; } }