public static long getSize ( File dir ) { long size = 0 ; for ( File file : dir . listFiles ( ) ) { if ( file . isFile ( ) ) { size += file . length ( ) ; } else { size += getSize ( file ) ; } } return size ; }
Returns the size of directory including all subfolders .