java判断路径、文件、文件夹是否存在

import java.io.File;

/**
* 判断指定路径的文件是否存在
*/
public class IsFileExists {

/**
* @param args
*/
public static void main(String[] args) {
  File file = new File("D://test//behind.rar");
  if (file.exists()) {
    System.out.println("文件:" + file.getPath() + "|||||存在");
  } else {
    System.out.println("文件:" + file.getPath() + "|||||不存在!");
  }
}

  

posted @ 2021-08-17 10:52  Ning-  阅读(1005)  评论(0编辑  收藏  举报