public static void read(DocumentBlock[] blocks,
byte[] buffer,
int offset) {
int firstBlockIndex = offset / PoiFSConstants.BIG_BLOCK_SIZE;
int firstBlockOffset = offset % PoiFSConstants.BIG_BLOCK_SIZE;
int lastBlockIndex = (offset + buffer.length - 1)
/ PoiFSConstants.BIG_BLOCK_SIZE;
if (firstBlockIndex == lastBlockIndex)
{
System.arraycopy(blocks[ firstBlockIndex ]._data,
firstBlockOffset, buffer, 0, buffer.length);
}
else
{
int buffer_offset = 0;
System.arraycopy(blocks[ firstBlockIndex ]._data,
firstBlockOffset, buffer, buffer_offset,
PoiFSConstants.BIG_BLOCK_SIZE
- firstBlockOffset);
buffer_offset += PoiFSConstants.BIG_BLOCK_SIZE - firstBlockOffset;
for (int j = firstBlockIndex + 1; j < lastBlockIndex; j++)
{
System.arraycopy(blocks[ j ]._data, 0, buffer, buffer_offset,
PoiFSConstants.BIG_BLOCK_SIZE);
buffer_offset += PoiFSConstants.BIG_BLOCK_SIZE;
}
System.arraycopy(blocks[ lastBlockIndex ]._data, 0, buffer,
buffer_offset, buffer.length - buffer_offset);
}
}
read data from an array of DocumentBlocks |