Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
    }
}