Trying to trouble Apache Tika using Java class error
Hello,
I'm new to IntelliJ and Java in general. I've set up IntelliJ, Maven, and Apache Tika on my local machine with the purpose of sending HTTP Get with the RTF code (base64 encoded) and use the Tika parser to parse it to plain text and return it back. I've gotten the code to mostly work, however, the handler comes back empty which I think is due to missing parser classes. Following this guide: https://wiki.apache.org/tika/Troubleshooting%20Tika#Parsers_Missing.
I'm trying to copy and paste in the code suggested seeing what parsers are installed, just underneath my public class Main code:
TikaConfig config = TikaConfig.getDefaultConfig();
CompositeParser parser = (CompositeParser)parser.getParser();
for (MediaType type : parser.getSupportedTypes(new ParseContext())) {
String typeStr = type.toString();
}
for (Parser p: parser.getAllComponentParsers()) {
String parserName = p.getClass().getName();
if (p instanceof CompositeParser) {
}
}
But I'm getting errors such as:
Unexpected token under the "for"
expected ';' after the "MediaType type"
cannot resolve symbol for "getSupportedTypes"
This is probably because I'm completely new to Java, any help would be great to help troubleshoot this issue.
Please sign in to leave a comment.
Hello,
Do you have "tika" library added to dependencies in "Project Structure | Modules - Dependencies"? Is it possible to navigate to "getSupportedTypes" method or "CompositeParser" class by Ctrl+Click on it?