Bug 62763 - HWPFDocument(POIFSFileSystem pfilesystem) Constructor exception
Summary: HWPFDocument(POIFSFileSystem pfilesystem) Constructor exception
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-26 10:21 UTC by snoopylovefiona
Modified: 2018-09-28 17:58 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?