package file;
import java.io.*;
public class FileCount
{
//全局变量的声明
public static int i=0,k=0;//i代表文件夹的个数,k代表文件的个数
public static void main(String [] args)
{
digui("E:/1");
System.out.println("目录的个数="+i+"\n文件的个数="+k);
}
public static void digui(String s)
{
File file = new File(s);
String[] str = file.list();
for (String str1 : str)
{
file = new File(s + "/" + str1);
if (file.isDirectory() && !file.isHidden())
{
System.out.println("目录:"+str1);
++i;
digui(s + "/" + str1);
}
else
{
System.out.println("文件:"+str1);
k++;
}
}
}
}