code: public static long getSize(final File aFile) {
          long size = 0;
  
          if (aFile != null && aFile.exists()) {
              if (aFile.isDirectory()) {
                  for (final File file : aFile.listFiles()) {
                      size += getSize(file);
                  }
              } else {
                  size += aFile.length();
              }
          }
  
          return size;
      }
docs: Gets the calculated size of a directory of files.
  
  @param aFile A file or directory from which to calculate size
  @return The calculated size of the supplied directory or file