Java tutorial
//package com.java2s; import java.io.File; public class Main { public static long getFileFolderSize(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 + getFileFolderSize(flist[i]); } else { size = size + flist[i].length(); } } return size; } }