Here you can find the source of getChecksum(byte[] buffer, int offset, int length)
public static long getChecksum(byte[] buffer, int offset, int length)
//package com.java2s; /**/* ww w. j av a 2 s . c o m*/ * Classe di utilities varie. * * <br><br>License: GNU General Public License<br> * * @author Pier Paolo Ciarravano * @version Vers. 0.98 (29/09/2009) */ import java.io.ByteArrayInputStream; import java.util.zip.Adler32; import java.util.zip.CheckedInputStream; public class Main { public static long getChecksum(byte[] buffer, int offset, int length) { long result = 0; try { ByteArrayInputStream bais = new ByteArrayInputStream(buffer, offset, length); CheckedInputStream cis = new CheckedInputStream(bais, new Adler32()); byte readBuffer[] = new byte[length]; cis.read(readBuffer, 0, length); result = cis.getChecksum().getValue(); //byte readBuffer[] = new byte[5]; //while (cis.read(readBuffer) >= 0) { // long value = cis.getChecksum().getValue(); // System.out.println("The value of checksum is " + value); //} } catch (Exception e) { System.out.println("Exception has been caught" + e); } return result; } }