Class MimeTypeUtil


  • public class MimeTypeUtil
    extends Object
    Utility class to detect MIME type based on data array.
    Author:
    iperdomo
    • Constructor Detail

      • MimeTypeUtil

        public MimeTypeUtil()
    • Method Detail

      • getInstance

        public static MimeTypeUtil getInstance()
        Returns the instance of the MimeTypeUtil class
        Returns:
        MimeTypeUtil instance
      • getMimeTypeName

        public String getMimeTypeName​(byte[] data)
        Returns the MIME type name, (e.g. image/png) based on the byte array passed as parameter. Returns application/octet-stream if no better match is found.
        Parameters:
        data - byte array from which we want to detect the MIME type
        Returns:
        MIME Type Name detected or application/octet-stream
      • getMimeTypeName

        public String getMimeTypeName​(File file)
        Returns the MIME type name, (e.g. image/png) based on the file content passed as parameter. Returns application/octet-stream if no better match is found.
        Parameters:
        file - file from which we want to detect the MIME type
        Returns:
        MIME Type Name detected or application/octet-stream