java.util.zip.CRC32.update() 方法示例



描述

java.util.zip.CRC32.update() 方法使用指定位元組陣列更新校驗和。

宣告

以下是 java.util.zip.CRC32.update() 方法的宣告。

public void update(byte[] b)

引數

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

示例

以下示例展示了 java.util.zip.CRC32.update() 方法的使用方法。

package com.tutorialspoint;

import java.util.zip.CRC32;

public class CRC32Demo {

   public static void main(String[] args) {
      String message = "Welcome to Tutorialspoint.com";
      byte bytes[] = message.getBytes();

      CRC32 checksum = new CRC32();
      checksum.reset();       

      checksum.update(bytes);
      long checksumValue = checksum.getValue();

      System.out.println("CRC32 checksum :" + checksumValue);
   }
}

讓我們編譯並執行上述程式,將產生以下結果 -

CRC32 checksum :1734172551
javazip_crc32.htm
廣告
© . All rights reserved.