Invalid header signature; read 0x3C0A0D0A0DBFBBEF, expected 0xE11AB1A1E011CFD0

读取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);
		
	}

猜你喜欢

转载自blog.csdn.net/hqbootstrap1/article/details/81283504
今日推荐