Java ByteBuffer Put putWithChecksum(ByteBuffer buffer, int value, Adler32 checksum)

Here you can find the source of putWithChecksum(ByteBuffer buffer, int value, Adler32 checksum)

Description

put With Checksum

License

Apache License

Declaration

static void putWithChecksum(ByteBuffer buffer, int value, Adler32 checksum) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

import java.util.zip.Adler32;

public class Main {
    static void putWithChecksum(ByteBuffer buffer, int value, Adler32 checksum) {
        buffer.putInt(value);//from  ww w  . j  a  v  a  2s.c o m
        checksum.update(value);
    }

    static void putWithChecksum(ByteBuffer buffer, long value, Adler32 checksum) {
        buffer.putLong(value);
        checksum.update((int) (value & 0xFFFFL));
        checksum.update((int) (value >> 32));
    }
}

Related

  1. putUnsignedShort(ByteBuffer bytes, int value)
  2. putUUID(ByteBuffer bytes, UUID uuid)
  3. putVarint(ByteBuffer buffer, long number, int byteSize)
  4. putVInt(ByteBuffer b, int i)
  5. putWhatFits(ByteBuffer dest, ByteBuffer src)
  6. read(InputStream is, ByteBuffer buf, int bytes)
  7. readAsByteBuffer(final InputStream source)
  8. readBER32(ByteBuffer input)
  9. readByteBuffer(DataInputStream is)