Java Long Number Create toLong(byte[] b)

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

Description

to Long

License

Apache License

Declaration

public static long toLong(byte[] b) 

Method Source Code

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

public class Main {
    public static long toLong(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;//w  w  w. j  av  a  2  s  .co  m
        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. toLong(byte... b)
  2. toLong(byte[] arr)
  3. toLong(byte[] array, int offset)
  4. toLong(byte[] b)
  5. toLong(byte[] b)
  6. toLong(byte[] b)
  7. toLong(byte[] b)
  8. toLong(byte[] b)
  9. toLong(byte[] b)