Here you can find the source of getTreeSize(File root)
public static long getTreeSize(File root)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { public static long getTreeSize(File root) { long size = 0; File files[] = root.listFiles(); if (files == null) return size; for (File file : files) { if (file.isDirectory()) size += getTreeSize(file); else//from www.jav a 2s . c om size += file.length(); } return size; } }