protected static final IconSet DEFAULT_ICONSET = IconSet.GYR_3_TRAFFIC_LIGHTS;\r
\r
/** Numeric ID of the icon set */\r
- public int id;\r
+ public final int id;\r
/** How many icons in the set */\r
public final int num;\r
/** Name (system) of the set */\r
@Override
public boolean equals(Object obj) {
- if (obj == null) return false;
+ if (!(obj instanceof CellKey)) {
+ return false;
+ }
// assumes other object is one of us, otherwise ClassCastException is thrown
final CellKey oKey = (CellKey) obj;
return _row == oKey._row && _col == oKey._col;
_fib.fillVariableFields(_mainStream, _tableStream);
// read in the data stream.
- try
- {
- DocumentEntry dataProps =
- (DocumentEntry)directory.getEntry(STREAM_DATA);
- _dataStream = new byte[dataProps.getSize()];
- directory.createDocumentInputStream(STREAM_DATA).read(_dataStream);
- }
- catch(java.io.FileNotFoundException e)
- {
+ InputStream dis = null;
+ try {
+ DocumentEntry dataProps = (DocumentEntry)directory.getEntry(STREAM_DATA);
+ dis = directory.createDocumentInputStream(STREAM_DATA);
+ _dataStream = IOUtils.toByteArray(dis, dataProps.getSize());
+ } catch(IOException e) {
_dataStream = new byte[0];
+ } finally {
+ if (dis != null) {
+ dis.close();
+ }
}
// Get the cp of the start of text in the main stream
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
super(directory);
// read in the main stream.
- DocumentEntry documentProps = (DocumentEntry)
- directory.getEntry("WordDocument");
- _mainStream = new byte[documentProps.getSize()];
-
- directory.createDocumentInputStream(STREAM_WORD_DOCUMENT).read(_mainStream);
+ DocumentEntry documentProps = (DocumentEntry)directory.getEntry("WordDocument");
+ DocumentInputStream dis = null;
+ try {
+ dis = directory.createDocumentInputStream(STREAM_WORD_DOCUMENT);
+ _mainStream = IOUtils.toByteArray(dis, documentProps.getSize());
+ } finally {
+ if (dis != null) {
+ dis.close();
+ }
+ }
// Create our FIB, and check for the doc being encrypted
_fib = new FileInformationBlock(_mainStream);