import java.io.File;
import java.text.DecimalFormat;
import java.io.FileInputStream;
public class GetFileSize
{
public long getFileSizes(File f) throws Exception{//取得文件大小
long s=0;
if (f.exists()) {
FileInputStream fis = null;
fis = new FileInputStream(f);
s= fis.available();
} else {
f.createNewFile();
System.out.println("文件不存在");
}
return s;
}
// 递归
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();
}
&