用遞歸算法遍歷文件下的所有子文件夾和子文件
文件夾遍歷方法
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("遍歷異常"); }
}