Java Byte Array to Long byteToLong(final byte[] b)

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

Description

Converts a given byte array to a long value

License

Open Source License

Parameter

Parameter Description
b Byte array to convert

Return

Long value

Declaration

public static long byteToLong(final byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w  ww  .j a v a 2s . c o m
     * Converts a given byte array to a long value
     *
     * @param b
     *            Byte array to convert
     * @return Long value
     */
    public static long byteToLong(final byte[] b) {
        long result = 0;
        for (int j = 0; j < 8; j++) {
            result <<= 8;
            result |= (b[j] & 0xFF);
        }

        return result;
    }
}

Related

  1. byteToLong(byte[] buf, int off)
  2. byteToLong(byte[] byteArray)
  3. byteToLong(byte[] bytesToConvert)
  4. byteToLong(byte[] i_Value)
  5. byteToLong(byte[] values)