Here you can find the source of appendLong(long value, ByteBuffer buffer)
Parameter | Description |
---|---|
value | a parameter |
buffer | a parameter |
public static ByteBuffer appendLong(long value, ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { private static final int MIN_REMAINING = 32; /**//ww w .j a v a 2s.c om * Append long to the end of the buffer, possibly reallocating it. * * @param value * @param buffer * @return */ public static ByteBuffer appendLong(long value, ByteBuffer buffer) { if (buffer.remaining() < 8) buffer = grow(buffer, MIN_REMAINING); buffer.putLong(value); return buffer; } private static ByteBuffer grow(ByteBuffer buffer, int minCapacityIncrease) { ByteBuffer tmp = ByteBuffer .allocate(Math.max(buffer.capacity() << 1, buffer.capacity() + minCapacityIncrease)); buffer.flip(); tmp.put(buffer); return tmp; } }