public static byte[] readAllBytes(java.nio.file.Path path) throws IOException {
        try (SeekableByteChannel channel = Files.newByteChannel(path);
                InputStream in = Channels.newInputStream(channel)) {

            long size = channel.size();
            if (size > (long) MAX_BUFFER_SIZE) {
                throw new OutOfMemoryError("Required array size too large");
            }

            return read(in, (int) size);
        }
    }
@Test
    void testReadAllBytes() throws Exception {

        File tempFile =
                TempDirUtils.newFolder(Paths.get(this.getClass().getResource("/").getPath()));

        final int fileSize = 1024;
        final String testFilePath =
                tempFile.toPath()
                        .resolve(this.getClass().getSimpleName() + "_" + fileSize + ".txt")
                        .toString();

        {
            String expectedMD5 = generateTestFile(testFilePath, 1024);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertThat(md5Hex(data)).isEqualTo(expectedMD5);
        }

        {
            String expectedMD5 = generateTestFile(testFilePath, 4096);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertThat(md5Hex(data)).isEqualTo(expectedMD5);
        }

        {
            String expectedMD5 = generateTestFile(testFilePath, 5120);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertThat(md5Hex(data)).isEqualTo(expectedMD5);
        }
    }