public static long getDU ( File dir ) { long size = 0 ; if ( ! dir . exists ( ) ) return 0 ; if ( ! dir . isDirectory ( ) ) { return dir . length ( ) ; } else { size = dir . length ( ) ; File [ ] allFiles = dir . listFiles ( ) ; for ( int i = 0 ; i < allFiles . length ; i ++ ) { size = size + getDU ( allFiles [ i ] ) ; } return size ; } }
Takes an input dir and returns the du on that local directory . Very basic implementation .