BlockRandomInputStream
is a specialized-yet-still-abstract
RandomAccessInputStream
that
is geared towards resources that are read block by block, either because of a particular constrain or for performance
reasons. This class typically comes in handy for network resources such as HTTP which have to request a block range
for reading the resource.
Seeking inside the file is implemented transparently by reading a block starting at the seek offset.
If
#seek(long) is called with an offset that is within the current block, no read occurs.
The block size should be carefully chosen as it affects seek performance and thus overall performance greatly:
the larger the block size, the more data is fetched when seeking outside the current block and consequently the
longer it takes to reposition the stream. On the other hand, a larger block size will yield better performance when
reading the resource sequentially, as it lessens the overhead of requesting a particular block.