Here you can find the source of folderSize(File directory)
public static long folderSize(File directory)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static long folderSize(File directory) { long length = 0; for (File file : directory.listFiles()) { if (file.isFile()) { length += file.length(); } else { length += folderSize(file); }//from w w w .j av a2s . c o m } return length; } }