com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class WordsMediaTypeDetector



  • public final class WordsMediaTypeDetector
    extends MediaTypeDetector

    Provides the functionality to detect the media type a text document.


    Supported formats:

    .DOCMicrosoft Word Text document
    .DOTMicrosoft Word Text template
    .DOCXMicrosoft Office Open XML Text document
    .DOCMMicrosoft Word 2007 Master document
    .RTFRich Text Format text file
    .ODTOpenDocument text
    .TXTPlain text
    .HTML (.XHTML, .HTM)Hypertext Markup Language document
    .MHTML (.MHT)Web Archive Single File

    Detecting the media type of a text document:

     // Create a media type detector of a text document
     MediaTypeDetector detector = new WordsMediaTypeDetector();
     // Detect a media type
     String mediaType = detector.detect(stream);
      
    • Constructor Detail

      • WordsMediaTypeDetector

        public WordsMediaTypeDetector()

        Initializes a new instance of the WordsMediaTypeDetector class.

    • Method Detail

      • detectByContent

        protected String detectByContent(InputStream stream)

        Detects the media type by the content of the stream.

        Overrides:
        detectByContent in class MediaTypeDetector
        Parameters:
        stream - Stream of the document.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
      • detectByExt

        protected String detectByExt(String ext)

        Detects the media type by the ext.

        Specified by:
        detectByExt in class MediaTypeDetector
        Parameters:
        ext - The extension of the file in the UPPER case.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
      • checkMediaType

        protected boolean checkMediaType(String mediaType)

        Detects whether the mediaType is supported by the detector.

        Specified by:
        checkMediaType in class MediaTypeDetector
        Parameters:
        mediaType - A string with media type in the UPPER case.
        Returns:
        A boolean true if the media type is supported; otherwise, false.