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

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

Description

to long.

License

Apache License

Parameter

Parameter Description
b byte array.

Return

long.

Declaration

public static long bytes2long(byte[] b) 

Method Source Code

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

public class Main {
    /**/* w ww . j  av  a 2 s.c  o  m*/
     * to long.
     * 
     * @param b byte array.
     * @return long.
     */
    public static long bytes2long(byte[] b) {
        return bytes2long(b, 0);
    }

    /**
     * to long.
     * 
     * @param b byte array.
     * @param off offset.
     * @return long.
     */
    public static long bytes2long(byte[] b, int off) {
        return ((b[off + 7] & 0xFFL) << 0) + ((b[off + 6] & 0xFFL) << 8) + ((b[off + 5] & 0xFFL) << 16)
                + ((b[off + 4] & 0xFFL) << 24) + ((b[off + 3] & 0xFFL) << 32) + ((b[off + 2] & 0xFFL) << 40)
                + ((b[off + 1] & 0xFFL) << 48) + (((long) b[off + 0]) << 56);
    }
}

Related

  1. byte2Long(byte[] bytes, int offset)
  2. byte2Long(byte[] bytes, int offset)
  3. byte2long(byte[] data)
  4. byte2long(byte[] value, int count)
  5. byte2long(final byte[] v)
  6. bytes2long(byte[] byteArray, int offset)
  7. bytes2long(byte[] bytes)
  8. bytes2long(byte[] bytes)
  9. bytes2Long(byte[] bytes)