Package java.util.zip

Class CRC32

java.lang.Object
java.util.zip.CRC32
All Implemented Interfaces:
Checksum

public class CRC32
extends Object
implements Checksum
The CRC32 class is used to compute a CRC32 checksum from data provided as input value. See also Adler32 which is almost as good, but cheaper.
  • Constructor Summary

    Constructors
    Constructor Description
    CRC32()  
  • Method Summary

    Modifier and Type Method Description
    long getValue()
    Returns the CRC32 checksum for all input received.
    void reset()
    Resets the CRC32 checksum to it initial state.
    void update​(byte[] buf)
    Updates this checksum with the bytes contained in buffer buf.
    void update​(byte[] buf, int offset, int byteCount)
    Update this CRC32 checksum with the contents of buf, starting from offset and reading byteCount bytes of data.
    void update​(int val)
    Updates this checksum with the byte value provided as integer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CRC32

      public CRC32()
  • Method Details

    • getValue

      public long getValue()
      Returns the CRC32 checksum for all input received.
      Specified by:
      getValue in interface Checksum
      Returns:
      The checksum for this instance.
    • reset

      public void reset()
      Resets the CRC32 checksum to it initial state.
      Specified by:
      reset in interface Checksum
    • update

      public void update​(int val)
      Updates this checksum with the byte value provided as integer.
      Specified by:
      update in interface Checksum
      Parameters:
      val - represents the byte to update the checksum.
    • update

      public void update​(byte[] buf)
      Updates this checksum with the bytes contained in buffer buf.
      Parameters:
      buf - the buffer holding the data to update the checksum with.
    • update

      public void update​(byte[] buf, int offset, int byteCount)
      Update this CRC32 checksum with the contents of buf, starting from offset and reading byteCount bytes of data.
      Specified by:
      update in interface Checksum
      Parameters:
      buf - the byte array from which to read the bytes.
      offset - the initial position in buf to read the bytes from.
      byteCount - the number of bytes to read from buf.