天天看點

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() + "|||||不存在!");
  }
}