Java ByteBuffer to Long Array getLongByteBuffer(long id)

Here you can find the source of getLongByteBuffer(long id)

Description

get Long Byte Buffer

License

Apache License

Declaration

public static final ByteBuffer getLongByteBuffer(long id) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    public static final int longSize = 8;

    public static final ByteBuffer getLongByteBuffer(long id) {
        ByteBuffer buffer = ByteBuffer.allocate(longSize);
        buffer.putLong(id);//ww w .j a v  a2 s  .  com
        buffer.flip();
        return buffer;
    }

    public static final ByteBuffer getLongByteBuffer(long[] ids) {
        ByteBuffer buffer = ByteBuffer.allocate(longSize * ids.length);
        for (int i = 0; i < ids.length; i++)
            buffer.putLong(ids[i]);
        buffer.flip();
        return buffer;
    }
}

Related

  1. getLong(ByteBuffer byteBuffer, int longIndex)
  2. getLong(ByteBuffer in)
  3. getLong(ByteBuffer longCalculator, byte[] bytes)
  4. getLongB(ByteBuffer bb, int index)
  5. getLongBE(ByteBuffer b, int start, int end)
  6. getLongFromBuffer(ByteBuffer buffer, int offset, int size)
  7. getLongFromByteBuffer(ByteBuffer data)
  8. getLongLE(final ByteBuffer b, final int start, final int end)
  9. getLongWithChecksum(ByteBuffer buffer, Adler32 checksum)