Java Byte Array to Long bytesToLong(byte[] bytes, int index)

Here you can find the source of bytesToLong(byte[] bytes, int index)

Description

bytes To Long

License

Open Source License

Declaration

public static long bytesToLong(byte[] bytes, int index) 

Method Source Code

//package com.java2s;

public class Main {
    public static long bytesToLong(byte[] bytes, int index) {
        return bytesToLong(bytes[index++], bytes[index++], bytes[index++],
                bytes[index++], bytes[index++], bytes[index++],
                bytes[index++], bytes[index++]);
    }/*from   w  w w.j a  v a  2 s . c o  m*/

    public static long bytesToLong(byte b1, byte b2, byte b3, byte b4,
            byte b5, byte b6, byte b7, byte b8) {
        long answer = 0xFFL & b8;
        answer = answer << 8 | (0xFF & b7);
        answer = answer << 8 | (0xFF & b6);
        answer = answer << 8 | (0xFF & b5);
        answer = answer << 8 | (0xFF & b4);
        answer = answer << 8 | (0xFF & b3);
        answer = answer << 8 | (0xFF & b2);
        answer = answer << 8 | (0xFF & b1);
        return answer;

    }
}

Related

  1. bytesToLong(byte[] bytes)
  2. bytesToLong(byte[] bytes)
  3. bytesToLong(byte[] bytes)
  4. bytesToLong(byte[] bytes)
  5. bytesToLong(byte[] bytes)
  6. bytesToLong(byte[] bytes, int off)
  7. bytesToLong(byte[] bytes, int off, boolean bigEndian)
  8. bytesToLong(byte[] data)
  9. bytesToLong(byte[] data)