集册 Java实例教程 确定文件或目录是否存在

确定文件或目录是否存在

欢马劈雪     最近更新时间:2020-01-02 10:19:05

477
确定文件或目录是否存在


import java.io.*;
/*
来 自*
 n o w j a   v  a . c o m - 时  代  Java
*/

 

public class Main {

 

  public static void main(String[] args) {

    File file = new File("C:/Folder/Demo.txt");

     boolean blnExists = file.exists();

   

     System.out.println("Does file " + file.getPath() + " exist ?: " + blnExists);

  }

}