code: public static long sizeOf(File file) {
  
      if (!file.exists()) {
        String message = file + " does not exist";
        throw new IllegalArgumentException(message);
      }
  
      if (file.isDirectory()) {
        return sizeOfDirectory(file);
      } else {
        return file.length();
      }
  
    }
docs: Returns the size of the specified file or directory. If the provided
  {@link File} is a regular file, then the file's length is returned.
  If the argument is a directory, then the size of the directory is
  calculated recursively. If a directory or subdirectory is security
  restricted, its size will not be included.
  
  @param file the regular file or directory to return the size
  of (must not be <code>null</code>).
  
  @return the length of the file, or recursive size of the directory,
  provided (in bytes).
  
  @throws NullPointerException if the file is <code>null</code>
  @throws IllegalArgumentException if the file does not exist.
  
  @since 2.0