Java File Size Get getFileSize(File file)

Here you can find the source of getFileSize(File file)

Description

get File Size

License

Open Source License

Declaration

public static long getFileSize(File file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static long getFileSize(File file) {
        if (file.isDirectory()) {
            long foldersize = 0;
            File[] filelist = file.listFiles();
            for (int i = 0; i < filelist.length; i++) {
                foldersize += getFileSize(filelist[i]);
            }//w  w w . ja  v a2s  .com
            return foldersize;
        } else {
            return file.length();
        }
    }
}

Related

  1. getFileSize(File f)
  2. getFileSize(File file)
  3. getFileSize(File file)
  4. getFileSize(File file)
  5. getFileSize(File file)
  6. getFileSize(File file)
  7. getFileSize(File file)
  8. getFileSize(File file)
  9. getFileSize(File file)