From: Nick Burch Date: Thu, 10 Aug 2006 12:20:24 +0000 (+0000) Subject: Throw a more useful exception in the case of word95 documents X-Git-Tag: REL_3_0_ALPHA3~56 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f3a4d0c4df8eeff1fddcf400a216677e3d2c970a;p=poi.git Throw a more useful exception in the case of word95 documents git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@430365 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java index 468c4a95c8..c525c57236 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java @@ -19,6 +19,7 @@ package org.apache.poi.hwpf; import java.io.InputStream; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.PushbackInputStream; import java.io.IOException; import java.io.OutputStream; @@ -153,9 +154,16 @@ public class HWPFDocument extends POIDocument name = "1Table"; } + // Grab the table stream. + DocumentEntry tableProps; + try { + tableProps = + (DocumentEntry)filesystem.getRoot().getEntry(name); + } catch(FileNotFoundException fnfe) { + throw new IllegalStateException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)"); + } + // read in the table stream. - DocumentEntry tableProps = - (DocumentEntry)filesystem.getRoot().getEntry(name); _tableStream = new byte[tableProps.getSize()]; filesystem.createDocumentInputStream(name).read(_tableStream);