[英]How to read doc file for the first four paragraph using Apache POI?
讀取doc文件並提取內容,能夠讀取整個doc文件,但是如何讀取doc文件中的前四段呢?
碼:
HWPFDocument doc = new HWPFDocument(fis);
WordExtractor we = new WordExtractor(doc);
String[] paragraphs = we.getParagraphText();
System.out.println("Total no of paragraph in the file "+paragraphs.length);
for (String para : paragraphs) {
System.out.println(para);
}
fis.close();
從上面它包含25個段落,那么我該如何閱讀前4個段落?
得到結果
for(int i=0;i<4;i++){
if(paragraphs[i] != null)
System.out.println(paragraphs[i]);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.