标签:absolute new length [] dir 路径 class file nbsp
用递归算法遍历文件下的所有子文件夹和子文件
文件夹遍历方法
public void getFileList(String strPath){
File f=new File(strPath);
try {
if(f.isDirectory()){
File[] fs=f.listFiles();
for(int i=0;i<fs.length;i++){
String fsPath=fs[i].getAbsolutePath();
System.out.printlen(fsPath);
getFileList(fsPath);
}
}else if(f.isFile()){
String fname=f.getAbsolutePath();
System.out.printlen(fname);
}else{
System.out.println("路径不正确!");
}
}catch (IOException e) {
System.out.println("遍历异常");
}
}
标签:absolute new length [] dir 路径 class file nbsp
原文地址:http://www.cnblogs.com/baconLiu/p/6743232.html