code: public static String getFormatFromURI(String uri, MimeType[] mimeTypes) {
          if (uri.endsWith("/")) {
              return null;
          }
  
          int idx = uri.lastIndexOf('/');
          if (idx > -1) {
              String lastToken = uri.substring(idx+1, uri.length());
              idx = lastToken.lastIndexOf('.');
              if (idx > -1 && idx != lastToken.length() - 1) {
                  String extension =  lastToken.substring(idx+1, lastToken.length());
                  if (mimeTypes != null) {
                      for (MimeType mimeType : mimeTypes) {
                          if (mimeType.getExtension().equals(extension)) return extension;
                      }
                  }
              }
          }
          return null;
      }
docs: Obtains the format from the URI. The format is the string following the . file extension in the last token of the URI.
  If nothing comes after the ".", this method assumes that there is no format and returns <code>null</code>.
  
  @param uri The URI
  @param mimeTypes The configured mime types
  @return The format or null if none