公共类考试{
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
.洋娃娃
ppt/幻灯片/_rels/幻灯片1.xml.rels
ppt/_rels/ppt.xml.rels
ppt/Presation.xml
ppt/幻灯片/幻灯片1.xml你好世界!
ppt/slideLayouts/_rels/sldeLayout6.xml.
ppt/slideLayouts/_rels/sldeLayout7.xml.
ppt/slideLayouts/_rels/sldeLayout9.xml.
ppt/slideLayouts/_rels/sldeLayout10.xml.
ppt/slideLayouts/_rels/sldeLayout8.xml.
ppt/slideLayouts/_rels/sldeLayout11.xml.
ppt/slideLayouts/_rels/sldeLayout1.xml.
ppt/slideLayouts/_rels/sldeLayout2.xml.
ppt/slideLayouts/_rels/sldeLayout3.xml.
ppt/slideLayouts/_rels/sldeLayout4.xml.
ppt/幻灯片母版/_rels/幻灯片Master1.xml.rels
ppt/幻灯片Fourth /幻灯片Layout11.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四层,第五层,1/30/2018年<#>
ppt/幻灯片Fourth /幻灯片Layout10.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四层,第五层,1/30/2018年<#>
ppt/slideLayouts/sldeLayout3.xml单击编辑主标题样式,单击编辑主文本样式1/30/2018 <#>
ppt/幻灯片Fourth /幻灯片Layout2.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四层,第五层,1/30/2018年<#>
ppt/slideLayouts/sldeLayout1.xml单击编辑主标题样式,单击编辑主字幕样式1/30/2018 <#>
ppt/幻灯片母版/幻灯片Master1.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四层,第五层,第1/30层/2018年<#>
ppt/幻灯片Fourth /幻灯片Layout4.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四级,第五层,编辑主文本样式,第二级,第三级,第四层,第五层,1/30/2018年<#>。
ppt/幻灯片Fourth /幻灯片Layout5.xml单击编辑主标题样式,单击编辑主文本样式,单击编辑主文本样式,第二级,第三级,第四层,第五层单击编辑主文本样式单击此处编辑主文本样式--第二级、第三级、第四层、第五层、第1/30层/2018年<#>
ppt/slideLayouts/sldeLayout6.xml单击以编辑主标题样式1/30/2018 <#>
ppt/slideLayouts/sldeLayout7.xml 1/30/2018 <#>
ppt/幻灯片Fourth /幻灯片Layout8.xml单击编辑主标题样式,单击编辑主文本样式,第二级,第三级,第四层,第五层,单击编辑主文本样式1/30/2018 <#>
ppt/slideLayouts/sldeLayout9.xml单击编辑主标题样式,单击编辑主文本样式1/30/2018 <#>
ppt/slideLayouts/_rels/sldeLayout5.xml.
ppt/theme/eme1.xml
/umbnail.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 Widescreen 1 1 0 0错误字体使用3主题1幻灯片标题1 Arial杯杯灯办公室主题PowerPoint演示假15.0000
发布于 2018-02-11 07:57:39
您可以尝试使用Tika -app.jar,只需使用Tika提取文本函数即可。
Tika tika = new Tika(); File file = new File("path"); String str = tika.parseToString(file);
此代码仅解析文件中的文本内容。
https://stackoverflow.com/questions/48705973
复制相似问题