/**
* 递归遍历文件夹
* @author songjie 2012.02.28
* @param file
* @param parentId:记录文件或者文件夹的层次
*/
public void visitTheWholeFolder(File file,long parentId){
if(file.canRead()){
if(file.isDirectory()){
System.out.println("this is a folder:"+file.getAbsolutePath()+" and parentId is:"+parentId);
File[] children = file.listFiles();
parentId++;
for(int i=0;i<children.length;i++){
this.visitTheWholeFolder(children[i],parentId);
}
}else{
System.out.println(file.getName()+" parentId is : "+parentId+" and path is "+file.getAbsolutePath());
}
}
}
学习元评论 (0条)
聪明如你,不妨在这 发表你的看法与心得 ~