Here you can find the source of getFileSize(File file)
public static long getFileSize(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static long getFileSize(File file) { if (file.isDirectory()) { long foldersize = 0; File[] filelist = file.listFiles(); for (int i = 0; i < filelist.length; i++) { foldersize += getFileSize(filelist[i]); }//w w w . ja v a2s .com return foldersize; } else { return file.length(); } } }