java.util.zip.CRC32.update( byte[] b, int off, int len ) 方法
描述
java.util.zip.CRC32.update(byte[] b, int off, int len) 方法使用指定的字节数组更新校验和。
声明
以下是 java.util.zip.CRC32.update(byte[] b, int off, int len) 方法的声明。
public void update(byte[] b, int off, int len)
参数
b − 用于更新校验和的字节数组。
off − 数据的起始偏移量。
len − 用于更新的字节数。
示例
以下示例显示了 java.util.zip.CRC32.update(byte[] b) 方法的用法。
package com.tutorialspoint;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
public class CRC32Demo {
public static void main(String[] args) {
String message = "Welcome to Tutorialspoint.com";
byte bytes[] = message.getBytes();
Checksum checksum = new CRC32();
checksum.reset();
checksum.update(bytes,0,bytes.length);
long checksumValue = checksum.getValue();
System.out.println("CRC32 checksum :" + checksumValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
CRC32 checksum :1734172551

