private static String tryTextyTypes(MediaType mediaType) {

            String type = mediaType.getType();
            String subtype = mediaType.getSubtype();
            if (type.equals(TEXT)) {
                switch (subtype) {
                    case HTML:
                        return HTML;
                    case PLAIN:
                        return "txt";
                    case CSS:
                        return CSS;
                    case CSV:
                        return CSV;
                }
            } else if (type.equals(APPLICATION)) {
                if (subtype.equals(XML)) {
                    return XML;
                } else if (subtype.equals(XHTML_XML)) {
                    return "html";
                }
            }
            return EMPTY_STRING;
        }
Utility method to convert from a string value representing a content type
(e.g. "application/pdf") into the most common extension for that file type
(e.g. "pdf").
<p>
This will has special handling for texty filetypes whose MimeTypes
don't currently return anything for {@link MimeType#getExtension};

@param contentType string representing a content type, for example: "application/pdf"
@param config      config from which to get MimeRepository
@return extension or empty string
@throws MimeTypeException thrown if MimeTypes can't parse the contentType
tika-eval/tika-eval-app/src/main/java/org/apache/tika/eval/app/db/MimeBuffer.java