Reading a Small File with the readAllBytes() Method - Java File Path IO

Java examples for File Path IO:File Operation

Description

Reading a Small File with the readAllBytes() Method

Demo Code

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    Path ball_path = Paths.get("C:/folder1/photos", "ball.png");

    try {/*from www.  ja v  a  2 s.co m*/
      byte[] ballArray = Files.readAllBytes(ball_path);
    } catch (IOException e) {
      System.out.println(e);
    }

  }
}

Result


Related Tutorials