Spread the love

Class CRC32 in Java

Spread the love

Class CRC32 in Java

CRC32 class implements the Checksum interface and computes a checksum on a stream of data using the CRC-32 algorithm. The CheckedInputStream and CheckedOutputStream classes provide a higher-level interface to computing checksums on streams of data.

This algorithm is significantly slower than Adler-32 and only slightly more reliable.

The class structure of Class CRC32 in Java is given as

public class java.util.zip.CRC32 extends java.lang.Object implements java.util.zip.Checksum {
// Default Constructor: 
public CRC32();
// Public Instance Methods
public long getValue(); // From Checksum
public void reset(); // From Checksum
public void update(int b); // From Checksum
public native void update(byte[] b, int off, int len); // From Checksum
public void update(byte[] b);
}

The details of the class structure are given as follows:

public CRC32();

public CRC32() constructor creates a CRC32 object.

public long getValue();

public long getValue() method returns the current value of this checksum.

This method returns the current checksum value.

public void reset();

public void reset() method resets the checksum to its initial value, making it appear as though it has not been updated by any data.

public void update(int b);

public void update(int b) method adds the specified value to the data stream and updates the checksum value. The
method uses only the lowest eight bits of the given int.

Parameter
b – The value to be added to the data stream for the checksum calculation.

public void update(byte[] b);

public void update(byte[] b) method adds the bytes from the specified array to the data stream and updates the checksum value.

READ  Class StreamCorruptedException in java
READ  EventObject Class in Java

Parameter
b – An array of bytes to be added to the data stream for the checksum calculation.

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

public native void update(byte[] b, int off, int len) method adds len bytes from the specified array, starting at off, to the data stream and updates the checksum value.

Parameter
b – An array of bytes to be added to the data stream for the checksum calculation.
off – An offset into the byte array.
len – The number of bytes to use.

Apart from these CRC32 class also has inherited methods from class- Object. They are as follows:

  • clone()
  • finalize()
  • hashCode()
  • notifyAll()
  • wait()
  • wait(long, int)
  • equals(Object)
  • getClass()
  • notify()
  • toString()
  • wait(long)




Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Learn How to Use Jacoco Java code Coverage

Introduction to Jacoco Jacoco provides a wide range of coverage(analysis of instructions,...

Comments

Recent Posts

Learn Quickly About DevOps Tools in a Fast and Efficient Manner

Introduction to DevOps tools DevOps tools are a collection of...

How to Collaborate between Development and Operations Team Fast and Effectively

Collaborate between Development and Operations Teams are the key...

Learn How to Use Jacoco Java code Coverage

Introduction to Jacoco Jacoco provides a wide range of coverage(analysis...

EDITOR PICKS


Spread the love