public static int getTotalOfFiles(String path) { int total = 0; int sum=0; File tmpF = new File(path); File[] files = tmpF.listFiles(); if(files ==null ) total = 0; else{ for(int i=0; i < files.length; i++) { if(files[i].isFile()) total++; else if(files[i].isDirectory()) sum = getTotalOfFiles(files[i].getAbsolutePath()); } total += sum; } return total; }
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/10657.html