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
This commit is contained in:
Nick Burch 2006-08-10 12:20:24 +00:00
parent b11c11fb65
commit ec2a2ca3ca

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf;
import java.io.InputStream; import java.io.InputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PushbackInputStream; import java.io.PushbackInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -153,9 +154,16 @@ public class HWPFDocument extends POIDocument
name = "1Table"; 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. // read in the table stream.
DocumentEntry tableProps =
(DocumentEntry)filesystem.getRoot().getEntry(name);
_tableStream = new byte[tableProps.getSize()]; _tableStream = new byte[tableProps.getSize()];
filesystem.createDocumentInputStream(name).read(_tableStream); filesystem.createDocumentInputStream(name).read(_tableStream);