Android Byte Array to Long Convert byteToLong(byte[] b)

Here you can find the source of byteToLong(byte[] b)

Description

byte To Long

License

Open Source License

Declaration

public static long byteToLong(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {

    public static long byteToLong(byte[] b) {
        if (b.length != 8) {
            return -1;
        }/*from  w  w  w .  j a  v a 2 s .  c om*/
        return ((((long) b[0] & 0xff) << 56) | (((long) b[1] & 0xff) << 48)
                | (((long) b[2] & 0xff) << 40)
                | (((long) b[3] & 0xff) << 32)
                | (((long) b[4] & 0xff) << 24)
                | (((long) b[5] & 0xff) << 16)
                | (((long) b[6] & 0xff) << 8) | (((long) b[7] & 0xff) << 0));
    }
}

Related

  1. byteArrayToLong(byte[] arr)
  2. byteArrayToLong(byte[] b)
  3. byteArrayToLong(byte[] bArray)
  4. bytesBE2long(byte[] b, int off)
  5. bytesBE2longs(byte[] b)
  6. bytesLE2long(byte[] b, int off)
  7. bytesLE2longs(byte[] b)
  8. bytesToLong(byte[] bytes)
  9. bytesToLong(byte[] bytes)