Android Byte Array to Long Convert getLong(byte[] bytes)

Here you can find the source of getLong(byte[] bytes)

Description

get Long

License

Open Source License

Declaration

public static long getLong(byte[] bytes) 

Method Source Code

//package com.java2s;

public class Main {
    public static long getLong(byte[] bytes) {
        return (0xffL & (long) bytes[0])
                | (0xff00L & ((long) bytes[1] << 8))
                | (0xff0000L & ((long) bytes[2] << 16))
                | (0xff000000L & ((long) bytes[3] << 24))
                | (0xff00000000L & ((long) bytes[4] << 32))
                | (0xff0000000000L & ((long) bytes[5] << 40))
                | (0xff000000000000L & ((long) bytes[6] << 48))
                | (0xff00000000000000L & ((long) bytes[7] << 56));
    }//w w w  .ja v a  2s .  c  o  m
}

Related

  1. bytes2ulong(byte[] bytes, int from, int to)
  2. getLong(byte[] bb, int index)
  3. getLong(byte[] bb, int index)
  4. getLong(byte[] buf, boolean bigEndian)
  5. getLong(byte[] buf, int pos, boolean bigEndian)
  6. getLong4(byte[] b, int offset)
  7. getLong5(byte[] b, int offset)
  8. getLongFromByteArray(final byte[] bytes)
  9. toLong(byte[] b, int pos)