Java Byte Array to Long bytes2long(byte[] bytes)

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

Description

byteslong

License

Apache License

Declaration

public static long bytes2long(byte[] bytes) 

Method Source Code

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

public class Main {
    public static long bytes2long(byte[] bytes) {
        long num = 0L;

        num = (((long) ((bytes[0] & 0xFF)) << 56) | ((long) ((bytes[1] & 0xFF)) << 48)
                | ((long) ((bytes[2] & 0xFF)) << 40) | ((long) ((bytes[3] & 0xFF)) << 32)
                | ((long) ((bytes[4] & 0xFF)) << 24) | ((long) ((bytes[5] & 0xFF)) << 16)
                | ((long) ((bytes[6] & 0xFF)) << 8) | ((long) ((bytes[7] & 0xFF))));

        return num;
    }/*from w w w . j  ava2s.co  m*/
}

Related

  1. bytes2Long(byte[] bytes)
  2. bytes2long(byte[] bytes)
  3. bytes2Long(byte[] bytes)
  4. bytes2Long(byte[] bytes)
  5. bytes2long(byte[] bytes)
  6. bytes2long(byte[] bytes, boolean bigEndian)
  7. bytes2Long(byte[] bytes, int offset)
  8. bytes2Long(final byte[] b)
  9. bytes2long(final byte[] bytes, final int start)