Javatpoint Logo
Javatpoint Logo

Tika Text File Extraction

To extract text file, Tika provides TXTParser class. This class is used to extract content and metadata from text file. It is located into org.apache.tika.parser.txt package.

This class contains constructor and methods that are tabled below.

Tika TextParser Constructor

Constructor Description
public TXTParser() It is used to create instance of the class.
public TXTParser(EncodingDetector encodingDetector) It creates instance with encoding detector.

Tika TextParser Methods

Method Description
public Set<MediaType> getSupportedTypes(ParseContext context) It returns the set of media types supported by this parser.
public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException It parses a document stream into a sequence of XHTML SAX events.

Tika Text File Extraction Example

In this example, we are extracting content and metadata from a text file. See the below example.

//javatpoint.txt

Our text file content.

Welcome to the Javatpoint.

Javatpoint is a Technical portal that contains latest computer science topics.

Output:

Document Content:Welcome to the Javatpoint.

Javatpoint is a Technical portal that contains latest computer science topics.


Document Metadata:
Content-Encoding:   ISO-8859-1
Content-Type:   text/plain; charset=ISO-8859-1

Next Topic#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA