Here you can find the source of set24BitInt(ByteBuffer buffer, int value)
Parameter | Description |
---|---|
buffer | the buffer |
value | the value |
private static final void set24BitInt(ByteBuffer buffer, int value)
//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)); } } }