Class MimeTypeHelper


  • public class MimeTypeHelper
    extends Object
    Helper class for mime types.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • MIMETYPE_APPLICATION_OCTETSTREAM

        public static final String MIMETYPE_APPLICATION_OCTETSTREAM
        mime type: application/octet-stream.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MimeTypeHelper

        public MimeTypeHelper()
    • Method Detail

      • getMimeType

        public static org.apache.tika.mime.MediaType getMimeType​(File file)
        Tries to determine the MIME type of a file by checking its magic bytes. Taken from here: http://stackoverflow.com/a/16626396.
        Parameters:
        file - the file to check
        Returns:
        the MIME type, MediaType.OCTET_STREAM if it fails
      • getMimeType

        public static org.apache.tika.mime.MediaType getMimeType​(String filename)
        Tries to determine the MIME type of a file by checking its magic bytes. Taken from here: http://stackoverflow.com/a/16626396.
        Parameters:
        filename - the file to check
        Returns:
        the MIME type, MediaType.OCTET_STREAM if it fails