Java Files check file existence

Description

Java Files check file existence

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) throws IOException {
    Path p = Paths.get("C:/Main.java");

    boolean b = Files.exists(p);
    System.out.println(b);/* w  w  w  .  j  a  va2  s  .com*/
  }
}



PreviousNext

Related