Java tutorial
//package com.java2s; import java.io.File; public class Main { public static double getSize(File file) { if (file.exists()) { if (!file.isFile()) { File[] fl = file.listFiles(); double ss = 0; for (File f : fl) { ss += getSize(f); } return ss; } else { double ss = (double) file.length() / 1024 / 1024; return ss; } } else { return 0.0; } } }