Android Big Endian to Long Convert bigEndToLong(byte[] array, int start)

Here you can find the source of bigEndToLong(byte[] array, int start)

Description

Converts a byte array into long from big-endian format.

Declaration

public static long bigEndToLong(byte[] array, int start) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w ww  .  ja  va 2s .co  m*/
     * Converts a byte array into long from big-endian format.
     * \param array The byte array to convert from.
     * \param start The starting point, int the array \a a, where the
     * conversion should start.
     * \returns The number after the conversion.
     **/
    public static long bigEndToLong(byte[] array, int start) {
        return (((long) (array[start + 0] & 0xFF) << 56)
                | ((long) (array[start + 1] & 0xFF) << 48)
                | ((long) (array[start + 2] & 0xFF) << 40)
                | ((long) (array[start + 3] & 0xFF) << 32)
                | ((long) (array[start + 4] & 0xFF) << 24)
                | ((long) (array[start + 5] & 0xFF) << 16)
                | ((long) (array[start + 6] & 0xFF) << 8) | ((long) (array[start + 7] & 0xFF)));
    }
}