Javatpoint Logo
Javatpoint Logo

Tika Auto Detector Parser

Tika AutoDetectParser is a class which automatically figure out what kind of content a file has, and then calls appropriate parser.

This class contains constructors and methods that are given below.

Tika AutoDetectParser Constructors

Constructor Description
public AutoDetectParser() It creates an auto-detecting parser instance using the default Tika configuration.
public AutoDetectParser(Detector detector) It creates an auto-detecting parser instance.
public AutoDetectParser(Parser... parsers) It creates an auto-detecting parser instance using the specified set of parser.
public AutoDetectParser(Detector detector, Parser... parsers) It creates an auto-detecting parser instance using the specified detector and parser.
public AutoDetectParser(TikaConfig config) Creates an auto-detecting parser instance using the specified set tika config.

Tika AutoDetectParser Methods

Following are the methods of Tika AutoDetectParser Class.

Method Description
public Detector getDetector() It returns the type detector used by this parser to auto-detect the type of a document.
public void setDetector(Detector detector) It sets the type detector used by this parser to auto-detect the type of a document.
public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException It is used to parse the input file.
public void parse(InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException It calls the Parser.parse(InputStream, ContentHandler, Metadata, ParseContext) method with an empty ParseContext.

Tika AutoDetectParser Example

Output:

Following is the content of hello.txt file after extraction.

Hello Welcome to Javatpoint





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA