使用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了,大佬們估計沒時間解決。