public static long fileLength(File file){
  long length=0L;
  if (file.isFile())   length=file.length();
 else   if (file.isDirectory()) {
    File[] files=file.listFiles();
    if (files != null) {
      for (      File f : files)       length+=fileLength(f);
    }
  }
  return length;
}

public static long fileLength ( File file ) { long length = 0L ; if ( file . isFile ( ) ) length = file . length ( ) ; else if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File f : files ) length += fileLength ( f ) ; } } return length ; }
returns the length of a file . if it is a directory it will calculate recursively the length .
