List of utility methods to do Directory Size Get
long | folderSize(File directory) folder Size long length = 0L; if (directory != null) { File[] files = directory.listFiles(); if (files == null) { return 0L; File[] arrayOfFile1; int j = (arrayOfFile1 = files).length; ... |
long | getDirLength(File dir) get Dir Length if (dir.isFile()) throw new IOException("BadInputException: not a directory."); long size = 0; File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; long length = 0; ... |
long | sizeOfDirectory(File directory) size Of Directory if (!directory.exists()) { String message = directory + " does not exist"; throw new IllegalArgumentException(message); if (!directory.isDirectory()) { String message = directory + " is not a directory"; throw new IllegalArgumentException(message); long size = 0; File[] files = directory.listFiles(); if (files == null) { return 0L; for (File file : files) { size += sizeOf(file); return size; |
long | sizeOf(File spec) Gets the size of a file or directory, in bytes. long size = 0; if (spec.isDirectory()) { String[] children = spec.list(); for (int i = 0; i < children.length; i++) { size += sizeOf(new File(spec, children[i])); } else { size = spec.length(); ... |
long | getDirectorySize(File f) get Directory Size if (f == null || !f.exists() || !f.isDirectory()) { return 0; long size = 0; File[] flist = f.listFiles(); if (flist != null) { for (int i = 0; i < flist.length; i++) { if (flist[i].isDirectory()) { ... |