日期:2014-05-20 浏览次数:20695 次
void loopFolder(String path){
File dir = new File(path);
File[] subFiles = dir.listFiles();
if (files == null){
System.out.println("path not found!");
}
for (int i = 0; i < subFiles.length; i++) {
if (subFiles[i].isDirectory()) {
loopFolder(subFiles[i].getAbsolutePath())
} else {
String strFileName = subFiles[i].getAbsolutePath().toLowerCase();
System.out.println("---" + strFileName);
}
}
}
public long getFileSize(File f)throws Exception//取得文件夹大小
{
long size = 0;
File flist[] = f.listFiles();
for (int i = 0; i < flist.length; i++)
{
if (flist[i].isDirectory())
{
size = size + getFileSize(flist[i]);
} else
{
size = size + flist[i].length();
}
}
return size;
}