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;
    }
  }
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.

@param dir
The input dir to get the disk space of this local dir
@return The total disk space of the input local directory