Java ByteBuffer to Long Array getLongB(ByteBuffer bb, int index)

Here you can find the source of getLongB(ByteBuffer bb, int index)

Description

get Long B

License

Open Source License

Declaration

private static long getLongB(ByteBuffer bb, int index) 

Method Source Code

//package com.java2s;
/**/*from   w  w  w  . j a va2s  .co  m*/
 * Copyright 2007-2016, Kaazing Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.ByteBuffer;

public class Main {
    private static long getLongB(ByteBuffer bb, int index) {
        return makeLong(bb.get(index), bb.get(index + 1),
                bb.get(index + 2), bb.get(index + 3), bb.get(index + 4),
                bb.get(index + 5), bb.get(index + 6), bb.get(index + 7));
    }

    private static long makeLong(byte b7, byte b6, byte b5, byte b4,
            byte b3, byte b2, byte b1, byte b0) {
        return (long) b7 << 56 | ((long) b6 & 0xff) << 48
                | ((long) b5 & 0xff) << 40 | ((long) b4 & 0xff) << 32
                | ((long) b3 & 0xff) << 24 | ((long) b2 & 0xff) << 16
                | ((long) b1 & 0xff) << 8 | (long) b0 & 0xff;
    }
}

Related

  1. deserializeLongArray(ByteBuffer buffer)
  2. getLong(ByteBuffer buffer)
  3. getLong(ByteBuffer byteBuffer, int longIndex)
  4. getLong(ByteBuffer in)
  5. getLong(ByteBuffer longCalculator, byte[] bytes)
  6. getLongBE(ByteBuffer b, int start, int end)
  7. getLongByteBuffer(long id)
  8. getLongFromBuffer(ByteBuffer buffer, int offset, int size)
  9. getLongFromByteBuffer(ByteBuffer data)