Here you can find the source of getFolderSize(File file)
public static long getFolderSize(File file)
//package com.java2s; import java.io.File; public class Main { public static long getFolderSize(File file) { long size = 0; File[] fileList = file.listFiles(); for (int i = 0; i < fileList.length; i++) { if (fileList[i].isDirectory()) { size = size + getFolderSize(fileList[i]); } else { size = size + fileList[i].length(); }// w w w . ja v a 2s . c o m } return size; } }