import java.io.File;
public class FileDemo {
/**
* 判断一个给定的路径是否是目录 isDirectory() 测试此抽象路径名表示的文件是否是一个目录。
*/
public static void main(String[] args) {
File file = new File( "e:" + File.separator); // 列出E盘的
if (file.isDirectory()) { // 判断e盘是否是目录
System.out.println(file.getPath() + "是目录");
//getPath() 将此抽象路径名转换为一个路径名字符串。
} else {
System.out.println(file.getPath() + "不是目录");
}
}
}
public class FileDemo {
/**
* 判断一个给定的路径是否是目录 isDirectory() 测试此抽象路径名表示的文件是否是一个目录。
*/
public static void main(String[] args) {
File file = new File( "e:" + File.separator); // 列出E盘的
if (file.isDirectory()) { // 判断e盘是否是目录
System.out.println(file.getPath() + "是目录");
//getPath() 将此抽象路径名转换为一个路径名字符串。
} else {
System.out.println(file.getPath() + "不是目录");
}
}
}
转载于:https://blog.51cto.com/haiyuanxi/931915