Java ByteBuffer Read readLink(ByteBuffer bb)

Here you can find the source of readLink(ByteBuffer bb)

Description

Read a 64-bit signed integer from the byte buffer, used as byte position within the file.

License

LGPL

Parameter

Parameter Description
bb The byte buffer.

Exception

Parameter Description
IOException an exception

Return

The value.

Declaration

public static long readLink(ByteBuffer bb) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    /**//  w  ww . j a v  a  2 s  . co m
     * Read a 64-bit signed integer from the byte buffer, used as byte position within the file. If a LINK is NIL
     * (corresponds to 0), this means the LINK cannot be de-referenced. A link must be a multiple of 8.
     * 
     * @param bb The byte buffer.
     * @return The value.
     * @throws IOException
     */
    public static long readLink(ByteBuffer bb) {
        byte[] data = new byte[8];
        bb.get(data);
        long l1 = (((long) data[0] & 0xff) << 0)
                | (((long) data[1] & 0xff) << 8)
                | (((long) data[2] & 0xff) << 16)
                | (((long) data[3] & 0xff) << 24);
        long l2 = (((long) data[4] & 0xff) << 0)
                | (((long) data[5] & 0xff) << 8)
                | (((long) data[6] & 0xff) << 16)
                | (((long) data[7] & 0xff) << 24);
        return (l1 << 0) | (l2 << 32);
    }
}

Related

  1. readHealthFloat16(ByteBuffer data)
  2. readHexString(ByteBuffer buffer, int nrBytes)
  3. readIso639(ByteBuffer bb)
  4. readKatakana(ByteBuffer b, char s[], int off, int len)
  5. readLen(ByteBuffer dup, int nls)
  6. readLink(ByteBuffer bb)
  7. readNewLine(ByteBuffer buf)
  8. readNullTerminatedString(ByteBuffer buf)
  9. readObject(ByteBuffer byteBuffer)