Examples of DetectedMimeTypeSet


Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @deprecated Use {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} or {@link #detectMimeTypes(File, DetectionStrategy)} instead!
   */
  public static String getMimeType(InputStream in)
  throws MimeException
  {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        in, null, DetectionStrategy.ONLY_CONTENT
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if while using the <code>magic.mime</code> rules there is a problem processing the file.
   * @deprecated Use {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} or {@link #detectMimeTypes(File, DetectionStrategy)} instead!
   */
  public static String getMimeType(String fname, boolean extFirst) throws MimeException {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        (RandomAccessFile)null, fname, DetectionStrategy.ONLY_CONTENT
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if while using the <code>magic.mime</code> rules there is a problem processing the file.
   * @deprecated Use {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} or {@link #detectMimeTypes(File, DetectionStrategy)} instead!
   */
  public static String getMimeType(File file, boolean extFirst) throws MimeException {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        file, file.getName(), extFirst ? DetectionStrategy.FILE_NAME_AND_CONTENT : DetectionStrategy.CONTENT_AND_FILE_NAME
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * This is a convenience method where the order of lookup is set to extension mapping first.
   * @see #getMimeType(File, boolean)
   * @deprecated Use {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} or {@link #detectMimeTypes(File, DetectionStrategy)} instead!
   */
  public static String getMimeType(File file) throws MimeException {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        file, file.getName(), DetectionStrategy.FILE_NAME_AND_CONTENT
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if the file cannot be parsed.
   * @deprecated Use {@link #detectMimeTypes(File, DetectionStrategy)} or {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} instead!
   */
  public static String getMagicMimeType(File file) throws MimeException {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        file, (String)null, DetectionStrategy.ONLY_CONTENT
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if the file cannot be parsed.
   * @deprecated Use {@link #detectMimeTypes(File, DetectionStrategy)} or {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} instead.
   */
  public static String getExtensionMimeTypes(File file) {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        (RandomAccessFile)null, file.getName(), DetectionStrategy.ONLY_FILE_NAME
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if the file cannot be parsed.
   * @deprecated Use {@link #detectMimeTypes(File, DetectionStrategy)} or {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} instead!
   */
  public static String getExtensionMimeTypes(String fname) {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        (RandomAccessFile)null, fname, DetectionStrategy.ONLY_FILE_NAME
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here

Examples of eu.medsea.mimeutil.detector.DetectedMimeTypeSet

   * @return the mime type. Never returns <code>null</code> (if the mime type cannot be found, {@link #UNKNOWN_MIME_TYPE} is returned).
   * @throws MimeException if the file cannot be parsed.
   * @deprecated Use {@link #detectMimeTypes(File, DetectionStrategy)} or {@link #detectMimeTypes(InputStream, String, DetectionStrategy)} instead!
   */
  public static String getMagicMimeType(String fname) throws MimeException {
    DetectedMimeTypeSet detectedMimeTypeSet = MimeTypeDetectorRegistry.sharedInstance().detectMimeTypes(
        (RandomAccessFile)null, fname, DetectionStrategy.ONLY_FILE_NAME
    );
    Collection c = detectedMimeTypeSet.getDetectedMimeTypes();
    if (c.isEmpty())
      return UNKNOWN_MIME_TYPE;

    return ((DetectedMimeType)c.iterator().next()).getMimeType();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.