Java ByteBuffer Set setLong(ByteBuffer buffer, long data)

Here you can find the source of setLong(ByteBuffer buffer, long data)

Description

set Long

License

Open Source License

Declaration

public static void setLong(ByteBuffer buffer, long data) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    public static void setLong(ByteBuffer buffer, long data) {

        assert (buffer.capacity() - buffer.position() >= 8);

        buffer.put((byte) (data & 0x00000000000000ffl));
        buffer.put((byte) ((data & 0x000000000000ff00l) >>> 8));
        buffer.put((byte) ((data & 0x0000000000ff0000l) >>> 16));
        buffer.put((byte) ((data & 0x00000000ff000000l) >>> 24));
        buffer.put((byte) ((data & 0x000000ff00000000l) >>> 32));
        buffer.put((byte) ((data & 0x0000ff0000000000l) >>> 40));
        buffer.put((byte) ((data & 0x00ff000000000000l) >>> 48));
        buffer.put((byte) ((data & 0xff00000000000000l) >>> 56));
    }//from ww w . ja va  2  s  .c  o  m
}

Related

  1. setBytesAtOffset(ByteBuffer buffer, int offset, int length, byte[] data)
  2. setCell(ByteBuffer buffer, int cellIndex, int cellbytes)
  3. setCreationTime(ByteBuffer buf, Date date)
  4. setFree(int frameIx, int offset, boolean free, ByteBuffer[] frames)
  5. setLimIfNeeded(ByteBuffer bb, int lim)
  6. setSByte(ByteBuffer buffer, byte data)
  7. setSInt(ByteBuffer buffer, int data)
  8. setString(ByteBuffer buffer, int index)
  9. setString(ByteBuffer buffer, String data)