public void writeTo ( final OutputStream out , long position , long length ) throws IOException { while ( length > 0 ) { final int index = index ( position ) ; final int offset = offset ( position ) ; final Block block = blocks . get ( index ) ; final int amount = ( int ) Math . min ( block . data . length - offset , length ) ; out . write ( block . data , offset , amount ) ; position += amount ; length -= amount ; } }
Write a specific segment of data from the buffer to a stream .