public class CreatFile {
public static void main (String[] args){
File f=new File("E:\\");
File list[]=f.listFiles();
for(int i=0;i<list.length;i++)
{
if (list[i].isDirectory())
{
System.out.println("目录名:"+list[i].getName()+list[i].getPath());
File f2=new File(list[i].getPath());
File list2[]=f2.listFiles();
continue;
}else
{
System.out.println("文件名:"+list[i].getName()+"文件大小:"+(list[i].length())/1024+"KB");
}
}
}
}
时间: 2024-11-03 22:40:27