日期:2014-05-17  浏览次数:20794 次

怎么样能让poi读取的word按原来的格式显示在页面
因为poi读取word 没法读取到空格和回车.这个问题要如何解决呢
poi java

------解决方案--------------------


public static void main(String[] args) {
File file = new File("D:/test.doc");
try {
FileInputStream fis = new FileInputStream(file);
HWPFDocument hwpfd = new HWPFDocument(fis);
WordExtractor wordExtractor = new WordExtractor(hwpfd);
String[] paragraph = wordExtractor.getParagraphText();
for (int i = 0; i < paragraph.length; i++) {
System.out.println(paragraph[i]);
}

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}