确定文件或目录
import java.io.File; /*来自 时代Java公众号*/ public class Main { public static void main(String[] args) { File file = new File("C://FileIO"); boolean isFile = file.isFile(); if (isFile) System.out.println(file.getPath() + " is a file."); else System.out.println(file.getPath() + " is not a file."); boolean isDirectory = file.isDirectory(); if (isDirectory) System.out.println(file.getPath() + " is a directory.");