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 int getFileSize(File file) {
        int result = 0;
        if (file == null) {
            return result;
        }
        if (!file.isDirectory()) {
            return (int) file.length();
        }
        if (file.listFiles() == null) {
            return result;
        }
        for (File item : file.listFiles()) {
            result += getFileSize(item);
        }
        return result;
    }
}