Java ByteBuffer Set set24BitInt(ByteBuffer buffer, int value)

Here you can find the source of set24BitInt(ByteBuffer buffer, int value)

Description

Places the given value into the given buffer as a 3 byte integer.

License

Open Source License

Parameter

Parameter Description
buffer the buffer
value the value

Declaration

private static final void set24BitInt(ByteBuffer buffer, int value) 

Method Source Code


//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    /**//from  w  w w.ja va2  s .  c o m
     * Places the given value into the given buffer as a 3 byte integer.
     * @param buffer the buffer
     * @param value the value
     */
    private static final void set24BitInt(ByteBuffer buffer, int value) {
        // check the byte order
        if (buffer.order() == ByteOrder.BIG_ENDIAN) {
            buffer.put((byte) (value >> 16));
            buffer.put((byte) ((value >>> 8) & 0xFF));
            buffer.put((byte) (value & 0xFF));
        } else {
            buffer.put((byte) (value & 0xFF));
            buffer.put((byte) ((value >>> 8) & 0xFF));
            buffer.put((byte) (value >> 16));
        }
    }
}

Related

  1. redString(ByteBuffer buffer, int offset, Charset charset)
  2. releaseTemporaryDirectBuffer(ByteBuffer buf)
  3. reset(int offset, ByteBuffer b)
  4. resetBit(ByteBuffer in, int pos)
  5. set0byte(MappedByteBuffer mem, byte value)
  6. setBatch(ByteBuffer bb, long batchId)
  7. setByteOrder(ByteBuffer buffer)
  8. setBytesAtOffset(ByteBuffer buffer, int offset, int length, byte[] data)
  9. setCell(ByteBuffer buffer, int cellIndex, int cellbytes)