Here you can find the source of readFile(String filename)
public static List<Byte> readFile(String filename)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { public static List<Byte> readFile(String filename) { List<Byte> result = new ArrayList<>(); try (FileInputStream file = new FileInputStream(filename)) { byte[] buffer = new byte[64 * 1024]; int bytesRead = 0; while ((bytesRead = file.read(buffer)) > 0) { for (int i = 0; i < bytesRead; i++) result.add(buffer[i]); }/* w ww . java 2s.com*/ } catch (IOException e) { throw new RuntimeException(e); } return result; } }