poi讀取doc報錯at org.apache.poi.util.LittleEndian.getUShort(LittleEndian.java:355)

使用poi讀取doc文檔時報錯

java.lang.ArrayIndexOutOfBoundsException: Index 65946 out of bounds for length 9355

	at org.apache.poi.util.LittleEndian.getUShort(LittleEndian.java:355)
	at org.apache.poi.hwpf.model.FileInformationBlock.<init>(FileInformationBlock.java:118)
	at org.apache.poi.hwpf.HWPFDocumentCore.<init>(HWPFDocumentCore.java:170)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:193)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:177)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:165)

代碼

StringBuilder buffer;
InputStream is = new FileInputStream(path);
HWPFDocument doc = new HWPFDocument(is);
StringBuilder buffer = doc.getText();

stackoverflow上面發現有人遇到同樣的問題,原來是apache的一個bug,並給出了apache提bug的入口,好多年的bug了,大佬們估計沒時間解決。

https://stackoverflow.com/questions/10831683/getting-java-lang-arrayindexoutofboundsexception-while-reading-doc-files-us

https://bz.apache.org/bugzilla/show_bug.cgi?id=39526

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章