Here you can find the source of getFolderSize(java.io.File file)
public static long getFolderSize(java.io.File file) throws Exception
//package com.java2s; public class Main { public static long getFolderSize(java.io.File file) throws Exception { long size = 0; java.io.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(); }/* ww w . j a va 2s .co m*/ } return size / 1024; } }