private long size(File file){
  if (file.isDirectory()) {
    long bytes=0;
    for (    File childFile : file.listFiles()) {
      bytes+=size(childFile);
    }
    return bytes;
  }
 else {
    return file.length();
  }
}

private long size ( File file ) { if ( file . isDirectory ( ) ) { long bytes = 0 ; for ( File childFile : file . listFiles ( ) ) { bytes += size ( childFile ) ; } return bytes ; } else { return file . length ( ) ; } }
calculate the size of the file or directory recursively .
