Java Path File Read nio readFromFile(Path absolutePath)

Here you can find the source of readFromFile(Path absolutePath)

Description

read From File

License

Open Source License

Declaration

public static byte[] readFromFile(Path absolutePath) throws IOException 

Method Source Code


//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();
    }
}

Related

  1. readFileIntoString(Path path)
  2. readFileLines(Path file)
  3. readFileRows(Path path)
  4. readFileToSingleString(String path)
  5. readFileToString(@Nonnull Path file)
  6. readFromFile(String path)
  7. readFromFile(String path)
  8. readFully(Path filePath)
  9. readIntsFromFile(String filePath)