Пример #1
0
 Collection getMimeTypes(final File file) throws MimeException {
   Collection mimeTypes = new ArrayList();
   try {
     if (!EncodingGuesser.getSupportedEncodings().isEmpty()) {
       mimeTypes = TextMimeDetector.getMimeTypes(file);
     }
   } catch (UnsupportedOperationException ignore) {
     // The TextMimeDetector will throw this if it decides
     // the content is not text
   }
   for (Iterator it = mimeDetectors.values().iterator(); it.hasNext(); ) {
     try {
       MimeDetector md = (MimeDetector) it.next();
       mimeTypes.addAll(md.getMimeTypes(file));
     } catch (UnsupportedOperationException usoe) {
       // We ignore this as it indicates that this MimeDetector does not support
       // Getting mime types from streams
     } catch (Exception e) {
       log.error(e.getLocalizedMessage(), e);
     }
   }
   return mimeTypes;
 }