用 poi 读取word文件 。
老是报错
org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0xC9D33C3A6D6F7246, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
public static void readAndWriterTest3() throws IOException {
File file = new File("D:\\jl\\2.doc");
String str = "";
try {
FileInputStream fis = new FileInputStream(file);
HWPFDocument doc = new HWPFDocument(fis);
String doc1 = doc.getDocumentText();
System.out.println(doc1);
StringBuilder doc2 = doc.getText();
System.out.println(doc2);
Range rang = doc.getRange();
String doc3 = rang.text();
System.out.println(doc3);
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
文件另存为之后,的word文档,就可以读取。这个要怎么解决,直接为什么读取不了?既然word能打开。为什么poi读取不了?
蛊毒传说
素胚勾勒不出你
相关分类