Java Utililty Methods ByteBuffer Put

List of utility methods to do ByteBuffer Put

Description

The list of methods to do ByteBuffer Put are organized into topic(s).

Method

voidputIntByteBuffer(ByteBuffer buf, int b)
Puts a byte (the first byte of an integer) into a ByteBuffer .
buf.put((byte) (b & 0xFF));
voidputIntLSBMSB(ByteBuffer byteBuffer, int value)
put Int LSBMSB
byteBuffer.order(ByteOrder.LITTLE_ENDIAN).putInt(value);
byteBuffer.order(ByteOrder.BIG_ENDIAN).putInt(value);
voidputNAL(ByteBuffer codecPrivate, ByteBuffer byteBuffer, int nalType)
put NAL
ByteBuffer dst = ByteBuffer.allocate(byteBuffer.remaining() * 2);
escapeNAL(byteBuffer, dst);
dst.flip();
codecPrivate.putInt(1);
codecPrivate.put((byte) nalType);
codecPrivate.put(dst);
voidputNullTerminal(ByteBuffer buffer)
Relative put operation.
Write a NULL terminal character in a ByteBuffer object.
buffer.put((byte) 0);
voidputObject(ByteBuffer byteBuffer, Object object)
put Object
if (object != null) {
    byteBuffer.put(TRUE);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream stream = new ObjectOutputStream(baos);
    stream.writeObject(object);
    byte[] array = baos.toByteArray();
    putByteArray(byteBuffer, array);
} else {
...
voidputObject(final ByteBuffer buffer, Serializable o)
Writes the given Serializable to the ByteBuffer.
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
    try (ObjectOutput oout = new ObjectOutputStream(bos)) {
        oout.writeObject(o);
        byte[] laneBytes = bos.toByteArray();
        buffer.putInt(laneBytes.length);
        for (int i = 0; i < laneBytes.length; i++) {
            buffer.put(laneBytes[i]);
} catch (IOException e) {
    e.printStackTrace();
voidputQuickchatParam(ByteBuffer buf, long param, int size)
put Quickchat Param
if (--size < 0 || size > 7) {
    throw new IllegalArgumentException();
for (int i = size * 8; i >= 0; i -= 8) {
    buf.put((byte) (param >> i));
voidputRange(ByteBuffer buffer, int start, int end, byte b)
Sets all bytes in the given byte range to the given byte value.
for (int i = start; i < end; ++i) {
    buffer.put(i, b);
voidputRGBfromHSB(final ByteBuffer pixels, final float[] hsb, int pixelSize)
put RG Bfrom HSB
int idx = 0;
for (int i = hsb.length / 3; --i >= 0;) {
    int r = 0, g = 0, b = 0;
    if (hsb[idx + 1] == 0)
        r = g = b = (int) (hsb[idx + 2] * 255.0f + 0.5f);
    else {
        float h = (hsb[idx + 0] - (float) Math.floor(hsb[idx + 0])) * 6.0f;
        float f = h - (float) Math.floor(h);
...
voidputStr(ByteBuffer buff, String str)
write a String to a ByteBuffer, prepended with a short integer representing the length of the String
if (str == null) {
    buff.putShort((short) 0);
} else {
    buff.putShort((short) str.length());
    buff.put(str.getBytes());