Here you can find the source of readFromFile(Path absolutePath)
public static byte[] readFromFile(Path absolutePath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.file.*; public class Main { public static byte[] readFromFile(Path absolutePath) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[8192]; int i;//from www . jav a 2s. c o m try (FileInputStream fis = new FileInputStream(absolutePath.toString())) { while ((i = fis.read(buffer)) != -1) { baos.write(buffer, 0, i); } } return baos.toByteArray(); } }