读取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个段落?
答案 0 :(得分:0)
得到结果
for(int i=0;i<4;i++){
if(paragraphs[i] != null)
System.out.println(paragraphs[i]);
}