Class MimeUtil

java.lang.Object
com.jk.core.mime.MimeUtil

public class MimeUtil extends Object
This class is an utility class for the MIME types.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Represents the unknown MIME type path filename used for types that aren't defined yet in the framework.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getMimeType(byte[] data)
    This method gets the MIME type of the data available in the provided byte array.
    static void
    init(InputStream mimeTypes, InputStream magicStream)
    This method initializes the Magic MIME database by loading MIME types and parsing magic rules from the provided input streams.
    static void
    main(String[] args)
    This main method is currently empty.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNKNOWN_MIME_TYPE

      public static final String UNKNOWN_MIME_TYPE
      Represents the unknown MIME type path filename used for types that aren't defined yet in the framework.
      See Also:
  • Constructor Details

    • MimeUtil

      public MimeUtil()
  • Method Details

    • getMimeType

      public static String getMimeType(byte[] data)
      This method gets the MIME type of the data available in the provided byte array.
      Parameters:
      data - Specifies the data to be tested
      Returns:
      the MIME type, or UNKNOWN_MIME_TYPE if no match is found.
    • init

      public static void init(InputStream mimeTypes, InputStream magicStream) throws IOException
      This method initializes the Magic MIME database by loading MIME types and parsing magic rules from the provided input streams.

      This method is typically called during application startup to configure the Magic MIME database.

      Parameters:
      mimeTypes - Specifies an InputStream containing MIME type definitions.
      magicStream - Specifies an InputStream containing magic rule definitions.
      Throws:
      IOException - if an I/O exception has occurred.
    • main

      public static void main(String[] args) throws FileNotFoundException, IOException
      This main method is currently empty.
      Parameters:
      args - the command line arguments.
      Throws:
      FileNotFoundException - if the file was not found.
      IOException - if an I/O exception has occurred.