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)

public void update(byte[] b, int off, int len)

  • 引數

  • b - 用於更新校驗和的位元組陣列。

  • off - 資料的開始偏移量。

len - 用於更新的位元組數。

示例

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);
   }
}

以下示例演示了 java.util.zip.CRC32.update(byte[] b) 方法的用法。

CRC32 checksum :1734172551
讓我們編譯並執行上述程式,這將產生以下結果 -
列印頁面
© . All rights reserved.