Bug 62763

Summary: HWPFDocument(POIFSFileSystem pfilesystem) Constructor exception
Product: POI Reporter: snoopylovefiona <986619781>
Component: HWPFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: normal    
Priority: P2    
Version: 4.0.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description snoopylovefiona 2018-09-26 10:21:26 UTC
my code:        
content = "1111";
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
        String realPathFile = DIR_IN + "empty.doc";
        POIFSFileSystem poifsFileSystem = new POIFSFileSystem(new FileInputStream(realPathFile));
        poifsFileSystem.createOrUpdateDocument(byteArrayInputStream, "WordDocument");
        HWPFDocument hwpfDocument = new HWPFDocument(poifsFileSystem);
        hwpfDocument.write(new FileOutputStream(DIR_OUT + outFileName));
        hwpfDocument.close();
        poifsFileSystem.close();
        byteArrayInputStream.close();
console exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11
	at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:253)
	at org.apache.poi.hwpf.model.types.FibBaseAbstractType.fillFields(FibBaseAbstractType.java:95)
	at org.apache.poi.hwpf.model.FibBase.<init>(FibBase.java:43)
	at org.apache.poi.hwpf.HWPFDocumentCore.getEncryptionInfo(HWPFDocumentCore.java:255)
	at org.apache.poi.hwpf.HWPFDocumentCore.getDocumentEntryBytes(HWPFDocumentCore.java:327)
	at org.apache.poi.hwpf.HWPFDocumentCore.<init>(HWPFDocumentCore.java:169)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:193)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:177)
	at com.snoopy.poi.HTML2doc.main(HTML2doc.java:55)
Comment 1 Dominik Stadler 2018-09-28 17:58:14 UTC
Seems the document is corrupt or at least confuses Apache POI, can you attach it? Does it open in Microsoft Word without errors being shown?