Instructions
- 1
Import the "Adler32" and "CheckedInputStream" modules, which calculate and store the checksum of a file or string. Use the following code:
import java.util.zip.CheckedInputStream;
import java.util.zip.Adler32;
Define a string value and convert it into a byte stream. Adler32 will only calculate checksums on incoming data streams:
String s = "This is the String";
byte buff[] = s.getBytes()'
ByteArrayInputStream ba = new ByteArrayInputStream(buff);
Calculate the checksum using an Adler32 object:
CheckedInputStream checked = new CheckedInputStream(ba, new Adler32());
No comments:
Post a Comment