Java Byte Array to Long 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;
//License from project: Open Source License 

public class Main {
    public static long byteToLong(byte[] b) {
        long s = 0;
        long s0 = b[0] & 0xff;
        long s1 = b[1] & 0xff;
        long s2 = b[2] & 0xff;
        long s3 = b[3] & 0xff;
        long s4 = b[4] & 0xff;
        long s5 = b[5] & 0xff;
        long s6 = b[6] & 0xff;
        long s7 = b[7] & 0xff;

        s1 <<= 8;//ww w  . ja  v a 2 s  .c  om
        s2 <<= 16;
        s3 <<= 24;
        s4 <<= 8 * 4;
        s5 <<= 8 * 5;
        s6 <<= 8 * 6;
        s7 <<= 8 * 7;
        s = s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7;
        return s;
    }
}

Related

  1. bytesToLong(final byte[] bytes)
  2. bytesToLong(final byte[] bytes)
  3. bytesToLong(final byte[] data, final int offset)
  4. bytesToLongLE(byte[] bytes, int off)
  5. byteToLong(byte[] b)
  6. byteToLong(byte[] buf, int off)
  7. byteToLong(byte[] byteArray)
  8. byteToLong(byte[] bytesToConvert)
  9. byteToLong(byte[] i_Value)