/** * Get the most specific match of the Collection of mime types passed in. The Collection * * @param mimeTypes this should be the Collection of mime types returned from a getMimeTypes(...) * call. * @return the most specific MimeType. If more than one of the mime types in the Collection have * the same value then the first one found with this value in the Collection is returned. */ public static MimeType getMostSpecificMimeType(final Collection mimeTypes) { MimeType mimeType = null; int specificity = 0; for (Iterator it = mimeTypes.iterator(); it.hasNext(); ) { MimeType mt = (MimeType) it.next(); if (mt.getSpecificity() > specificity) { mimeType = mt; specificity = mimeType.getSpecificity(); } } return mimeType; }