Here you can find the source of getCrcChecksum(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | The buffer. |
public static int getCrcChecksum(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.util.zip.CRC32; import java.util.zip.Checksum; public class Main { /**/*w ww . ja va2s . com*/ * Calculates the CRC32 checksum of the specified buffer. * @param buffer The buffer. * @return The CRC32 checksum. */ public static int getCrcChecksum(ByteBuffer buffer) { Checksum crc = new CRC32(); for (int i = 0; i < buffer.limit(); i++) { crc.update(buffer.get(i)); } return (int) crc.getValue(); } }