Java ByteBuffer Write writeVarLong(ByteBuffer buff, long x)

Here you can find the source of writeVarLong(ByteBuffer buff, long x)

Description

Write a variable size int.

License

Open Source License

Parameter

Parameter Description
buff the target buffer
x the value

Declaration

public static void writeVarLong(ByteBuffer buff, long x) 

Method Source Code

//package com.java2s;
/*//from w w  w  .j  av  a  2s.com
 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
 * Version 1.0, and under the Eclipse Public License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */

import java.nio.ByteBuffer;

public class Main {
    /**
     * Write a variable size int.
     *
     * @param buff the target buffer
     * @param x the value
     */
    public static void writeVarLong(ByteBuffer buff, long x) {
        while ((x & ~0x7f) != 0) {
            buff.put((byte) (0x80 | (x & 0x7f)));
            x >>>= 7;
        }
        buff.put((byte) x);
    }
}

Related

  1. writeUnsignedVarInt(int value, ByteBuffer dest)
  2. writeUTF8StringToByteBuffer(String str, ByteBuffer bb)
  3. writeUUID(ByteBuffer buffer, UUID uuid)
  4. writeV(ByteBuffer byteBuffer, List vint)
  5. writeVarint(int value, ByteBuffer buffer)
  6. writeVarLong(ByteBuffer buff, long x)
  7. writeVarLong(long n, ByteBuffer buff)
  8. writeVarLong(long value, ByteBuffer buf)
  9. writeVInt(ByteBuffer bb, int i)