private boolean checkJDKExisted(String resourcePath) throws Exception
{
File file = new File("E:/files/JDK");
File[] fileList = file.listFiles();
for (int i = 0; i < fileList.length; i++)
{
if (fileList[i].isFile())
{
String fileName = fileList[i].getName();
System.out.println("文件名:" + fileName);
}
if (fileList[i].isDirectory())
{
String fileName = fileList[i].getName();
System.out.println("目录:" + fileName);
}
}
return true;
}
fileList[i].isFile()和fileList[i].isDirectory()均为布尔类型,目标为文件时fileList[i].isFile()
为TRUE,目标为目录时fileList[i].isDirectory()为true。