public void calculateChunkedSums ( ByteBuffer data , ByteBuffer checksums ) { if ( size == 0 ) return ; if ( data . hasArray ( ) && checksums . hasArray ( ) ) { calculateChunkedSums ( data . array ( ) , data . arrayOffset ( ) + data . position ( ) , data . remaining ( ) , checksums . array ( ) , checksums . arrayOffset ( ) + checksums . position ( ) ) ; return ; } data . mark ( ) ; checksums . mark ( ) ; try { byte [ ] buf = new byte [ bytesPerChecksum ] ; while ( data . remaining ( ) > 0 ) { int n = Math . min ( data . remaining ( ) , bytesPerChecksum ) ; data . get ( buf , 0 , n ) ; summer . reset ( ) ; summer . update ( buf , 0 , n ) ; checksums . putInt ( ( int ) summer . getValue ( ) ) ; } } finally { data . reset ( ) ; checksums . reset ( ) ; } }
Calculate checksums for the given data .