Android Folder Size Get getFolderSize(java.io.File file)

Here you can find the source of getFolderSize(java.io.File file)

Description

get Folder Size

Declaration

public static long getFolderSize(java.io.File file) throws Exception 

Method Source Code

//package com.java2s;

public class Main {
    public static long getFolderSize(java.io.File file) throws Exception {
        long size = 0;
        java.io.File[] fileList = file.listFiles();
        for (int i = 0; i < fileList.length; i++) {
            if (fileList[i].isDirectory()) {
                size = size + getFolderSize(fileList[i]);
            } else {
                size = size + fileList[i].length();
            }/* ww  w  . j  a  va  2s  .co m*/
        }
        return size / 1024;
    }
}

Related

  1. getSize(final File path)
  2. getFolderSize(File file)