/*
Generate Adler32 Checksum For Byte Array Example
This Java example shows how to get the Adler32 checksum value for
array of bytes using Adler32 Java class.
*/
import java.util.zip.Adler32;
import java.util.zip.Checksum;
public class CalculateAdler32ForByteArray {
public static void main(String args[]){
String str = "Generate Adler32 Checksum For Byte Array Example";
//Convert string to bytes
byte bytes[] = str.getBytes();
Checksum checksum = new Adler32();
/*
* To compute the Adler32 checksum for byte array, use
*
* void update(bytes[] b, int start, int length)
* method of Adler32 class.
*/
checksum.update(bytes,0,bytes.length);
/*
* Get the generated checksum using
* getValue method of Adler32 class.
*/
long lngChecksum = checksum.getValue();
System.out.println("Adler32 checksum for byte array is :" + lngChecksum);
}
}
/*
Output of this program would be
Adler32 checksum for byte array is :2593132786
*/
Bookmark/Search this post with:
Post new comment