Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.TextUtils;
import java.io.File;

public class Main {

    private static long getFileSize(String path) {
        if (TextUtils.isEmpty(path)) {
            return 0;
        }
        File filePath = new File(path);
        File[] itemList = filePath.listFiles();
        long totalSize = 0;
        if (null != itemList) {
            for (File f : itemList) {
                if (f.exists() && f.isFile() && f.length() > 0) {
                    totalSize = totalSize + f.length();
                }
            }
        }
        return totalSize;
    }
}