code: public static String parseFileExtension(String filename) {
          // if null, return null
          if (filename == null) {
              return null;
          }
          // find position of last period
          int pos = filename.lastIndexOf('.');
          // did one exist or have any length?
          if (pos < 0 || (pos+1) >= filename.length()) {
              return null;
          }
          // parse extension
          return filename.substring(pos+1);
      }
docs: Parse the filename and return the file extension.  For example, if the
  file is "app.2006-10-10.log", then this method will return "log".  Will
  only return the last file extension.  For example, if the filename ends
  with ".log.gz", then this method will return "gz"
  @param String to process containing the filename
  @return The file extension (without leading period) such as "gz" or "txt"
  or null if none exists.