Here you can find the source of readFully(Path filePath)
public static byte[] readFully(Path filePath) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; public class Main { public static byte[] readFully(Path filePath) throws FileNotFoundException, IOException { return readFully(new FileInputStream(filePath.toFile())); }//from w ww . j a va2 s . c om public static byte[] readFully(InputStream inputStream) throws IOException { byte[] buffer = new byte[131072]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); while ((bytesRead = inputStream.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } return output.toByteArray(); } }