create a new HeaderBlockReader from an InputStream
_data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ];
int byte_count = IOUtils.readFully(stream, _data);
if (byte_count != POIFSConstants.BIG_BLOCK_SIZE)
{
if (byte_count == -1)
//Cant have -1 bytes read in the error message!
byte_count = 0;
String type = " byte" + ((byte_count == 1) ? ("")
: ("s"));
throw new IOException("Unable to read entire header; "
+ byte_count + type + " read; expected "
+ POIFSConstants.BIG_BLOCK_SIZE + " bytes");
}
// verify signature
LongField signature = new LongField(_signature_offset, _data);
if (signature.get() != _signature)
{
// Is it one of the usual suspects?
if(_data[0] == 0x50 && _data[1] == 0x4b && _data[2] == 0x03 &&
_data[3] == 0x04) {
throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents");
}
// Give a generic error
throw new IOException("Invalid header signature; read "
+ signature.get() + ", expected "
+ _signature);
}
_bat_count = new IntegerField(_bat_count_offset, _data);
_property_start = new IntegerField(_property_start_offset, _data);
_sbat_start = new IntegerField(_sbat_start_offset, _data);
_xbat_start = new IntegerField(_xbat_start_offset, _data);
_xbat_count = new IntegerField(_xbat_count_offset, _data);