In this tutorial, we will discuss the use of Adler32 class. The Adler32 class used to compute the checksum of data stream.It creates a input stream for reading bytes from file. The Adler32 class class is available in java.util.zip package. Alder32 checksum work faster then CRC32.
With the help of this example, you will see how to compute the Adler32 checksum of file. First of all, we will create an object of Adler32. The FileInputStream class create input stream for reading bytes from file.The CheckedOutputStream class is used to compute the checksum of the data begin written on the output stream. The getValue() method of the Adler32 class return value of checksum, and reset() method of the Adler32 class reset the checksum value with initial value.
About Adler32 API:
The java.util.zip.Adler32 class extends java.lang.Object class. It provide following methods:
|checksum||getValue()||The getValue() method returns value of checksum.|
|void||reset()||The reset() method reset the checksum value at initial value.|
value of Adler32 checkSum :1
Name of file : testfile.txt
value of Adler32 checkSum after reading a file :1843857417
value of Adler32 CheckSum After reseting :1
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.