测试

    /**

* 读取文件夹大小

* @param file

* @return

*/

public static long getTotalSizeOfFilesInDir(final File file) {

if(file.isFile()){

return file.length();

}

final File[] children = file.listFiles(); 

long total = 0;

if(children != null){

for (final File child : children){

total += getTotalSizeOfFilesInDir(child); 

}

}

return total;

}


你可能感兴趣的:(技术,博客)