com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class CsvMediaTypeDetector



  • public final class CsvMediaTypeDetector
    extends MediaTypeDetector

    Provides the functionality to detect CSV's media type.

    Detecting the media type of CSV file:

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

      • CsvMediaTypeDetector

        public CsvMediaTypeDetector()

        Initializes a new instance of the CsvMediaTypeDetector class.

      • CsvMediaTypeDetector

        public CsvMediaTypeDetector(Integer maxLinesCount,
                            Integer maxLineLength)

        Initializes a new instance of the CsvMediaTypeDetector class.

        Parameters:
        maxLinesCount - A maximum lines of file to exam.
        maxLineLength - A maximum line of text in the CSV file.
    • Method Detail

      • 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.
      • 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.