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

private long size ( File file ) { long size = 0 ; if ( file . isDirectory ( ) ) { for ( File subFile : file . listFiles ( ) ) { size += size ( subFile ) ; } } else { size = file . length ( ) ; } return size ; }
calculate a file or a folder size
