Adler32
Stay organized with collections
Save and categorize content based on your preferences.
A class that can be used to compute the Adler-32 checksum of a data
stream. An Adler-32 checksum is almost as reliable as a CRC-32 but
can be computed much faster.
Passing a null
argument to a method in this class will cause
a NullPointerException
to be thrown.
Public Constructor Summary
|
Adler32()
Creates a new Adler32 object.
|
Public Method Summary
long
|
|
void
|
reset()
Resets the checksum to initial value.
|
void
|
update(byte[] b)
Updates the checksum with the specified array of bytes.
|
void
|
update( ByteBuffer buffer)
Updates the checksum with the bytes from the specified buffer.
|
void
|
update(byte[] b, int off, int len)
Updates the checksum with the specified array of bytes.
|
void
|
update(int b)
Updates the checksum with the specified byte (the low eight
bits of the argument b).
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
From interface
java.util.zip.Checksum
abstract
long
|
getValue()
Returns the current checksum value.
|
abstract
void
|
reset()
Resets the checksum to its initial value.
|
abstract
void
|
update(byte[] b, int off, int len)
Updates the current checksum with the specified array of bytes.
|
abstract
void
|
update(int b)
Updates the current checksum with the specified byte.
|
Public Constructors
public
Adler32
()
Creates a new Adler32 object.
Public Methods
public
long
getValue
()
Returns the checksum value.
Returns
- the current checksum value
public
void
reset
()
Resets the checksum to initial value.
public
void
update
(byte[] b)
Updates the checksum with the specified array of bytes.
Parameters
b |
the byte array to update the checksum with
|
public
void
update
(ByteBuffer buffer)
Updates the checksum with the bytes from the specified buffer.
The checksum is updated using
buffer.remaining()
bytes starting at
buffer.position()
Upon return, the buffer's position will be updated to its
limit; its limit will not have been changed.
Parameters
buffer |
the ByteBuffer to update the checksum with |
public
void
update
(byte[] b, int off, int len)
Updates the checksum with the specified array of bytes.
Parameters
b |
the byte array to update the checksum with |
off |
the start offset of the data |
len |
the number of bytes to use for the update
|
public
void
update
(int b)
Updates the checksum with the specified byte (the low eight
bits of the argument b).
Parameters
b |
the byte to update the checksum with
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eAdler32\u003c/code\u003e class computes the Adler-32 checksum of a data stream, offering a faster alternative to CRC-32 with comparable reliability.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to update the checksum with byte arrays, \u003ccode\u003eByteBuffer\u003c/code\u003e objects, or individual bytes, and to reset and retrieve the checksum value.\u003c/p\u003e\n"],["\u003cp\u003ePassing a \u003ccode\u003enull\u003c/code\u003e argument to any method in this class will result in a \u003ccode\u003eNullPointerException\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAdler32\u003c/code\u003e implements the \u003ccode\u003eChecksum\u003c/code\u003e interface and inherits methods from the \u003ccode\u003eObject\u003c/code\u003e class.\u003c/p\u003e\n"]]],["The `Adler32` class computes Adler-32 checksums. Key actions include creating an `Adler32` object, updating the checksum with bytes from an array, a buffer, or a single byte using `update()`, getting the current checksum value with `getValue()`, and resetting the checksum to its initial value via `reset()`. The `update()` method has overloads to process different data sources. Passing a null argument will cause a `NullPointerException` error.\n"],null,["# Adler32\n\npublic class **Adler32** extends [Object](../../../../reference/java/lang/Object.html) \nimplements [Checksum](../../../../reference/java/util/zip/Checksum.html) \nA class that can be used to compute the Adler-32 checksum of a data\nstream. An Adler-32 checksum is almost as reliable as a CRC-32 but\ncan be computed much faster.\n\nPassing a `null` argument to a method in this class will cause\na [NullPointerException](../../../../reference/java/lang/NullPointerException.html) to be thrown. \n\n##### See Also\n\n- [Checksum](../../../../reference/java/util/zip/Checksum.html) \n\n### Public Constructor Summary\n\n|---|-------------------------------------------------------------------------------------------------------|\n| | [Adler32](../../../../reference/java/util/zip/Adler32.html#Adler32())() Creates a new Adler32 object. |\n\n### Public Method Summary\n\n|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| long | [getValue](../../../../reference/java/util/zip/Adler32.html#getValue())() Returns the checksum value. |\n| void | [reset](../../../../reference/java/util/zip/Adler32.html#reset())() Resets the checksum to initial value. |\n| void | [update](../../../../reference/java/util/zip/Adler32.html#update(byte[]))(byte\\[\\] b) Updates the checksum with the specified array of bytes. |\n| void | [update](../../../../reference/java/util/zip/Adler32.html#update(java.nio.ByteBuffer))([ByteBuffer](../../../../reference/java/nio/ByteBuffer.html) buffer) Updates the checksum with the bytes from the specified buffer. |\n| void | [update](../../../../reference/java/util/zip/Adler32.html#update(byte[],%20int,%20int))(byte\\[\\] b, int off, int len) Updates the checksum with the specified array of bytes. |\n| void | [update](../../../../reference/java/util/zip/Adler32.html#update(int))(int b) Updates the checksum with the specified byte (the low eight bits of the argument b). |\n\n### Inherited Method Summary\n\nFrom class [java.lang.Object](../../../../reference/java/lang/Object.html) \n\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../reference/java/lang/Object.html) | [clone](../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../reference/java/lang/String.html) | [toString](../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nFrom interface [java.util.zip.Checksum](../../../../reference/java/util/zip/Checksum.html) \n\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract long | [getValue](../../../../reference/java/util/zip/Checksum.html#getValue())() Returns the current checksum value. |\n| abstract void | [reset](../../../../reference/java/util/zip/Checksum.html#reset())() Resets the checksum to its initial value. |\n| abstract void | [update](../../../../reference/java/util/zip/Checksum.html#update(byte[],%20int,%20int))(byte\\[\\] b, int off, int len) Updates the current checksum with the specified array of bytes. |\n| abstract void | [update](../../../../reference/java/util/zip/Checksum.html#update(int))(int b) Updates the current checksum with the specified byte. |\n\nPublic Constructors\n-------------------\n\n#### public\n**Adler32**\n()\n\nCreates a new Adler32 object.\n\nPublic Methods\n--------------\n\n#### public long\n**getValue**\n()\n\nReturns the checksum value. \n\n##### Returns\n\n- the current checksum value \n\n#### public void\n**reset**\n()\n\nResets the checksum to initial value. \n\n#### public void\n**update**\n(byte\\[\\] b)\n\nUpdates the checksum with the specified array of bytes. \n\n##### Parameters\n\n| b | the byte array to update the checksum with |\n|---|--------------------------------------------|\n\n#### public void\n**update**\n([ByteBuffer](../../../../reference/java/nio/ByteBuffer.html) buffer)\n\nUpdates the checksum with the bytes from the specified buffer.\n\nThe checksum is updated using\nbuffer.[remaining()](../../../../reference/java/nio/Buffer.html#remaining())\nbytes starting at\nbuffer.[position()](../../../../reference/java/nio/Buffer.html#position())\nUpon return, the buffer's position will be updated to its\nlimit; its limit will not have been changed. \n\n##### Parameters\n\n| buffer | the ByteBuffer to update the checksum with |\n|--------|--------------------------------------------|\n\n#### public void\n**update**\n(byte\\[\\] b, int off, int len)\n\nUpdates the checksum with the specified array of bytes. \n\n##### Parameters\n\n| b | the byte array to update the checksum with |\n| off | the start offset of the data |\n| len | the number of bytes to use for the update |\n|-----|--------------------------------------------|\n\n##### Throws\n\n| [ArrayIndexOutOfBoundsException](../../../../reference/java/lang/ArrayIndexOutOfBoundsException.html) | if `off` is negative, or `len` is negative, or `off+len` is greater than the length of the array `b` |\n|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|\n\n#### public void\n**update**\n(int b)\n\nUpdates the checksum with the specified byte (the low eight\nbits of the argument b). \n\n##### Parameters\n\n| b | the byte to update the checksum with |\n|---|--------------------------------------|"]]