日期:2014-05-17 浏览次数:20742 次
public static void main(String[] args) throws Exception {
StringBuffer stringBuffer=new StringBuffer();
File file= new File("D:\\121.doc");
//获得文件输入流
FileInputStream input = new FileInputStream(file);
//创建Document对象
HWPFDocument doc = new HWPFDocument(input);
//用来获得word文档内容
Range range=doc.getRange();
//文档段落数目
int paragraphCount=range.numParagraphs();
//遍历段落读取数据
for(int i=0;i<paragraphCount;i++)
{
Paragraph pph=range.getParagraph(i);
stringBuffer.append(pph.text());
System.out.println(stringBuffer.toString());
}
}