java.util.zip.Adler32 update()方法

java.util.zip.Adler32 update(byte[] b, int off, int len)  方法 介绍

java.util.zip.Adler32.update(byte[] b, int off, int len)  方法更新与指定的字节数组的校验和。

java.util.zip.Adler32 update(byte[] b, int off, int len)  方法 声明

public void update(byte[] b, int off, int len)
  • b : 用于更新校验和的字节数组。

  • off : 数据的起始偏移量。

  • len : 用于更新的字节数。

java.util.zip.Adler32 update(byte[] b, int off, int len) 方法 示例

下面的例子展示了 java.util.zip.Adler32.update(byte[] b)  方法的用法。

package com.yiidian;

import java.util.zip.Adler32;
import java.util.zip.Checksum;

public class Adler32Demo {

   public static void main(String[] args) {
      String message = "Welcome to yiidian.com";
      byte bytes[] = message.getBytes();
      Checksum checksum = new Adler32();
      checksum.reset();       
      checksum.update(bytes,0,bytes.length);
      long checksumValue = checksum.getValue();
      System.out.println("Adler32 checksum :" + checksumValue);
   }
}

输出结果为:

热门文章

优秀文章