【发布时间】:2018-02-11 15:57:39
【问题描述】:
公共类测试{
public static void main(String[] args) throws Exception{
String data;
TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
Metadata metadata = new Metadata();
ContentHandler handler;
try (InputStream stream = new BufferedInputStream(new FileInputStream(new File("E:\\AllTypes\\PPT\\Presentation1.pptx")))) {
Detector detector = tikaConfig.getDetector();
Parser parser = tikaConfig.getParser();
MediaType type = detector.detect(stream, metadata);
metadata.set(Metadata.CONTENT_TYPE, type.toString());
handler = new BodyContentHandler(-1);
parser.parse(stream, handler, metadata, new ParseContext());
data = handler.toString();
System.out.println(data);
}
}
}
我只有你好世界!在输入 ppt 所以我只想要你好世界! 输出:[Content_Types].xml
_rels/.rels
ppt/slides/_rels/slide1.xml.rels
ppt/_rels/presentation.xml.rels
ppt/presentation.xml
ppt/slides/slide1.xml 你好世界!
ppt/slideLayouts/_rels/slideLayout6.xml.rels
ppt/slideLayouts/_rels/slideLayout7.xml.rels
ppt/slideLayouts/_rels/slideLayout9.xml.rels
ppt/slideLayouts/_rels/slideLayout10.xml.rels
ppt/slideLayouts/_rels/slideLayout8.xml.rels
ppt/slideLayouts/_rels/slideLayout11.xml.rels
ppt/slideLayouts/_rels/slideLayout1.xml.rels
ppt/slideLayouts/_rels/slideLayout2.xml.rels
ppt/slideLayouts/_rels/slideLayout3.xml.rels
ppt/slideLayouts/_rels/slideLayout4.xml.rels
ppt/slideMasters/_rels/slideMaster1.xml.rels
ppt/slideLayouts/slideLayout11.xml 点击编辑主标题样式 点击编辑主文本样式 二级 三级 四级 五级 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout10.xml 点击编辑主标题样式 点击编辑主文本样式 二级 三级 四级 五级 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout3.xml 点击编辑主标题样式 点击编辑主文本样式 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout2.xml 点击编辑主标题样式 点击编辑主文本样式 二级 三级 四级 五级 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout1.xml 点击编辑主标题风格 点击编辑主字幕风格 1/30/2018 ‹#›
ppt/slideMasters/slideMaster1.xml 点击编辑主标题样式 点击编辑主文本样式 二级 三级 四级 五级 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout4.xml 点击编辑主标题样式点击编辑主文本样式二级三级四级五级点击编辑主文本样式二级三级四级五级1/30/2018 ‹#›
ppt/slideLayouts/slideLayout5.xml 点击编辑 主标题样式 点击编辑 主文本样式 点击编辑 主文本样式 二级 三级 第四级 第五级 点击编辑 主文本样式 点击编辑 主文本样式 二级 三级 第四级 第五级 1/30/ 2018 ‹#›
ppt/slideLayouts/slideLayout6.xml 点击编辑主标题样式 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout7.xml 2018 年 1 月 30 日 ‹#›
ppt/slideLayouts/slideLayout8.xml 点击编辑 主标题样式 点击编辑 主文本样式 二级 三级 第四级 第五级 点击编辑 主文本样式 1/30/2018 ‹#›
ppt/slideLayouts/slideLayout9.xml 点击编辑主标题样式 点击编辑主文本样式 1/30/2018 ‹#›
ppt/slideLayouts/_rels/slideLayout5.xml.rels
ppt/theme/theme1.xml
docProps/thumbnail.jpeg
ppt/presProps.xml
ppt/tableStyles.xml
ppt/viewProps.xml
docProps/core.xml PowerPoint 演示文稿 srinuk srinuk 1 2018-01-30T10:19:34Z 2018-01-30T10:22:05Z
docProps/app.xml 2 3 Microsoft Office PowerPoint 宽屏 1 1 0 0 0 false 使用的字体 3 主题 1 幻灯片标题 1 Arial Calibri Calibri Light Office 主题 PowerPoint 演示文稿 false false false 15.0000
【问题讨论】:
-
如果使用 AutoDetectParser 会发生什么?您是如何将 Tika 添加到您的项目中的?您是否可能忘记了一些依赖项?
标签: apache-tika