get Long from byte array - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

get Long from byte array

Demo Code


//package com.java2s;

public class Main {
    public static long getLong(byte[] bb) {
        return ((((long) bb[0] & 0xff) << 56)
                | (((long) bb[1] & 0xff) << 48)
                | (((long) bb[2] & 0xff) << 40)
                | (((long) bb[3] & 0xff) << 32)
                | (((long) bb[4] & 0xff) << 24)
                | (((long) bb[5] & 0xff) << 16)
                | (((long) bb[6] & 0xff) << 8) | (((long) bb[7] & 0xff) << 0));
    }/* w  w  w .  jav a2 s. co  m*/
}

Related Tutorials