package World; import java.io.FileNotFoundException; import java.io.IOException; import org.apache.poi.POIXMLDocument; import org.apache.poi.POIXMLTextExtractor; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; public class World { public static void main(String[] args) { try { OPCPackage oPCPackage = POIXMLDocument.openPackage("D://resource/world.docx"); XWPFDocument xwpf = new XWPFDocument(oPCPackage); POIXMLTextExtractor ex = new XWPFWordExtractor(xwpf); System.out.print(ex.getText()); oPCPackage.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
目录结构及效果
来源:http://blog.sina.com.cn/s/blog_acdc06250101jfj2.html
时间: 2024-10-23 04:06:56