Here you can find the source of writeVarLong(ByteBuffer buff, long x)
Parameter | Description |
---|---|
buff | the target buffer |
x | the value |
public static void writeVarLong(ByteBuffer buff, long x)
//package com.java2s; /*//from w ww .java2 s . c o m * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (http://h2database.com/html/license.html). * Initial Developer: H2 Group */ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; public class Main { /** * Write a variable size long. * * @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); } /** * Write a variable size long. * * @param out the output stream * @param x the value */ public static void writeVarLong(OutputStream out, long x) throws IOException { while ((x & ~0x7f) != 0) { out.write((byte) (0x80 | (x & 0x7f))); x >>>= 7; } out.write((byte) x); } }