public static long sizeOfDirectory(File directory){
  checkDirectory(directory);
  final File[] files=directory.listFiles();
  if (files == null) {
    return 0L;
  }
  long size=0;
  for (  final File file : files) {
    try {
      if (!isSymlink(file)) {
        size+=sizeOf(file);
        if (size < 0) {
          break;
        }
      }
    }
 catch (    IOException ioe) {
    }
  }
  return size;
}

public static long sizeOfDirectory ( File directory ) { checkDirectory ( directory ) ; final File [ ] files = directory . listFiles ( ) ; if ( files == null ) { return 0L ; } long size = 0 ; for ( final File file : files ) { try { if ( ! isSymlink ( file ) ) { size += sizeOf ( file ) ; if ( size < 0 ) { break ; } } } catch ( IOException ioe ) { } } return size ; }
counts the size of a directory recursively ( sum of the length of all files ) .
