我试图用 Apache Tika 解析 iWorksDoc。但我没有得到解析的内容,因为它是从内容处理程序获取一些其他输出。 我使用的代码片段和我得到的输出添加在下面。
private void parseFile(File file) {
try{
File file = new File("/home/user/tika/samples/budget.numbers");
FileInputStream inputStream = new FileInputStream(file);
ParseContext context = new ParseContext();
BodyContentHandler bodyHandler = new BodyContentHandler(-1);
Parser parser=new AutoDetectParser();
parser.parse(inputStream, bodyHandler, new Metadata(), context);
System.out.println("Contents of the file :"+bodyHandler.toString());
}
catch(IOException | SAXException | TikaException e){
e.printStackTrace();
}
}
输出:-
Contents of the file :
Index/Document.iwa
Index/ViewState.iwa
Index/CalculationEngine.iwa
Index/Tables/HeaderStorageBucket-2.iwa
Index/Tables/Tile.iwa
Index/Metadata.iwa
Metadata/Properties.plist
我能够使用 Detector api 正确检测文件类型。但我没有从文档中获取有用的内容。请帮忙!
最佳答案
Tika 应该能够解析 Numbers 文档。如果您能够分享该文档,请将其发布到我们的Jira 。当我查看解析器时,我们可以更稳健地处理命名空间,这可能是问题所在,但如果没有文档我就无法判断。
关于java - 使用 Apache Tika 解析 iWorksDocument 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36892547/