Java Long Number Create toLong(final byte[] data)

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

Description

Converts the big-endian representation of a 64-bit integer to the equivalent long value.

License

Open Source License

Parameter

Parameter Description
data 8-byte array in big-endian format.

Return

Long integer value.

Declaration

public static long toLong(final byte[] data) 

Method Source Code

//package com.java2s;
/* See LICENSE for licensing and NOTICE for copyright. */

public class Main {
    /**//from  www  .  j a  va2  s. c o  m
     * Converts the big-endian representation of a 64-bit integer to the
     * equivalent long value.
     *
     * @param  data  8-byte array in big-endian format.
     *
     * @return  Long integer value.
     */
    public static long toLong(final byte[] data) {
        return ((long) data[0] << 56) | (((long) data[1] & 0xff) << 48) | (((long) data[2] & 0xff) << 40)
                | (((long) data[3] & 0xff) << 32) | (((long) data[4] & 0xff) << 24)
                | (((long) data[5] & 0xff) << 16) | (((long) data[6] & 0xff) << 8) | ((long) data[7] & 0xff);
    }
}

Related

  1. toLong(double[] v)
  2. toLong(final byte[] array, final int offset, final int length)
  3. toLong(final byte[] b)
  4. toLong(final byte[] b, final int offset)
  5. toLong(final byte[] bytes, final int offset)
  6. toLong(final byte[] data)
  7. toLong(final byte[] inputBytes, int offset)
  8. toLong(final Object o, final String pattern)
  9. toLong(final Object obj)