public class File_Directory {
public static int fileCount = 0;
public static void main(String args[])
{
String dir = "f:/java";
print_file(dir);
System.out.println("文件夹"+dir+"下文件总数:"+fileCount);
}
public static void print_file (String dir)
{
File file = new File(dir);
System.out.println("目录"+file.getAbsolutePath()+"下的子文件:");
File files[] = file.listFiles();
for(File tempFile : files)
{
if(tempFile.isDirectory())
{
System.out.println("目录"+tempFile.getAbsolutePath()+"下的子文件:");
print_file(tempFile.getAbsolutePath());
}else{
fileCount++;
System.out.println(tempFile.getAbsolutePath());
}
}
}
}
阅读(5583) | 评论(0) | 转发(0) |