Class MimeUtil

java.lang.Object
com.saperion.util.MimeUtil

public final class MimeUtil extends Object
This MimiUtil can be used to get a MIME type by filenames in a convenient way. Use it like this: MimeUtil.getMimeType("myFile.pdf").
Author:
sts
  • Field Details

    • DEFAULT_MIMETYPE

      public static final String DEFAULT_MIMETYPE
      The default MIME type to be used if no MIME type matches.
      See Also:
  • Method Details

    • initialize

      protected static void initialize()
      Initializes the MimetypesFileTypeMap used by this util.
    • getMimeType

      public static String getMimeType(String filename)
      Returns the MIME type matching the given filename.
      Parameters:
      filename - The filename to get the MIME type of.
      Returns:
      the MIME type or "application/octet-stream" if no matching MIME could be found or the util could not be initialized properly.
    • getMimeTypeByPath

      public static String getMimeTypeByPath(String path)
      Returns the MIME type matching the given path (path/[/path...]/filename).
      Parameters:
      path - The filename to get the MIME type of.
      Returns:
      the MIME type or "application/octet-stream" if no matching MIME could be found or the util could not be initialized properly.
    • getFilename

      @Deprecated public static String getFilename(String path)
      Deprecated.
      Will be removed in 8.1. Use MultipageDocUtil.getFilename(String) instead.
      Extracts and returns the filename of the given path. Strips the possible '@' postfix.
      Parameters:
      path - The path+filename to be extract the filename from.
      Returns:
      The extracted filename.