Class Crc32


  • public final class Crc32
    extends java.lang.Object
    计算文件或二进制数据的crc32校验码
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long bytes​(byte[] data)
      计算二进制字节校验码
      static long bytes​(byte[] data, int offset, int length)
      计算二进制字节校验码
      static long file​(java.io.File f)
      对文件内容计算crc32校验码
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • bytes

        public static long bytes​(byte[] data,
                                 int offset,
                                 int length)
        计算二进制字节校验码
        Parameters:
        data - 二进制数据
        offset - 起始字节索引
        length - 校验字节长度
        Returns:
        校验码
      • bytes

        public static long bytes​(byte[] data)
        计算二进制字节校验码
        Parameters:
        data - 二进制数据
        Returns:
        校验码
      • file

        public static long file​(java.io.File f)
                         throws java.io.IOException
        对文件内容计算crc32校验码
        Parameters:
        f - 需要计算crc32校验码的文件
        Returns:
        crc校验码
        Throws:
        java.io.IOException - 读取文件异常