Tika is a collection of tools for content extraction (a toolkit for text extracting). It integrates the POI, PDFBox and provides a unified interface for text extraction work. Second, Tika also provides a convenient extension API to enrich its support for third-party file formats.
In the current version of 0.2-snapshot, Tika provides support for the following file formats:
- PDF-Via PDFBox
- ms-*-Via POI
- HTML-use nekohtml to defragment an irregular HTML into XHTML
- OpenOffice Format-Tika offers
- Archive-zip, TAR, gzip, bzip, etc.
- Rtf-tika offers
- Java Class-class parsing is done by ASM
- Image-only meta-data extraction for images is supported
- Xml
The Tika API is very handy, and the core is parser interface, which defines a parse method:
public void parse(InputStream stream, ContentHandler handler, Metadata metadata)
Use the stream parameter to pass the file stream that needs to be parsed, the text content is passed into the handler, and the metadata is updated to metadata.
You can use the Tika parserutils tool to get an appropriate parser based on the file to mime-type
parse the work. Or Tika also provides a autodetectparser to find the right parser, depending on the particular format of the binary file (for example, Magic Code).
Apache Open Source Project--tika