读取word文档报错 错误信息 Invalid header signature; read 0x3C0A0D0A0DBFBBEF, expected 0xE11AB1A1E011CFD0
private final static String filePath = "D:/Test.doc";
public static void main(String[] args) throws FileNotFoundException, IOException {
FileInputStream stream = new FileInputStream(filePath);
System.out.println(stream);
HWPFDocument doc = new HWPFDocument(new FileInputStream(filePath));
System.out.println(doc);
}
解决办法:将读取那个文档,另存为一个文件就好,重新读取
private final static String filePath = "D:/TestNew.doc";
public static void main(String[] args) throws FileNotFoundException, IOException {
FileInputStream stream = new FileInputStream(filePath);
System.out.println(stream);
HWPFDocument doc = new HWPFDocument(new FileInputStream(filePath));
System.out.println(doc);
}