Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static long getFolderSize(File dir) { long size = 0; try { File[] fileList = dir.listFiles(); for (int i = 0; i < fileList.length; i++) { if (fileList[i].isDirectory()) { size += getFolderSize(fileList[i]); } else { size += fileList[i].length(); } } } catch (Exception e) { e.printStackTrace(); } return size; } }