Java ByteBuffer Put writePackedLong(ByteBuffer output, long value)

Here you can find the source of writePackedLong(ByteBuffer output, long value)

Description

write Packed Long

License

Open Source License

Declaration

public static int writePackedLong(ByteBuffer output, long value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static int writePackedLong(ByteBuffer output, long value) {
        assert value >= 0; //
        int position = output.position();
        while (value > 127) {
            output.put((byte) ((value & 127) + ((value > 127 ? 1 : 0) << 7)));
            value >>= 7;/*from   w w  w . j a  va2 s. c om*/
        }
        output.put((byte) (value & 127));
        return position;
    }
}

Related

  1. writeBytes(OutputStream os, ByteBuffer buffer)
  2. writeFully(ByteBuffer buffer, OutputStream os)
  3. writeFully(OutputStream out, ByteBuffer buf)
  4. writeOutputStream(OutputStream output, ByteBuffer data)
  5. writeOutputStreamWriter(String str, int offset, int count, OutputStream out, ByteBuffer bytes, CharsetEncoder encoder, Object lock)
  6. writeShortByteArray(ByteBuffer name, DataOutput out)
  7. writeTo(ByteBuffer buffer, OutputStream out)
  8. writeVarInt(ByteBuffer buffer, int input)