Java Byte Array to Long bytesToLong(byte[] bytes)

Here you can find the source of bytesToLong(byte[] bytes)

Description

bytes To Long

License

GNU General Public License

Declaration

public static long bytesToLong(byte[] bytes) 

Method Source Code

//package com.java2s;
/*//from w ww. j a va 2 s .c  om
 * This is the source code of Telegram for Android v. 2.x.x.
 * It is licensed under GNU GPL v. 2 or later.
 * You should have received a copy of the license in this archive (see LICENSE).
 *
 * Copyright Nikolai Kudashov, 2013-2015.
 */

public class Main {
    public static long bytesToLong(byte[] bytes) {
        return ((long) bytes[7] << 56) + (((long) bytes[6] & 0xFF) << 48) + (((long) bytes[5] & 0xFF) << 40)
                + (((long) bytes[4] & 0xFF) << 32) + (((long) bytes[3] & 0xFF) << 24)
                + (((long) bytes[2] & 0xFF) << 16) + (((long) bytes[1] & 0xFF) << 8) + ((long) bytes[0] & 0xFF);
    }
}

Related

  1. bytesToLong(byte[] bytes)
  2. bytesToLong(byte[] bytes)
  3. bytesToLong(byte[] bytes)
  4. bytesToLong(byte[] bytes)
  5. bytesToLong(byte[] bytes)
  6. bytesToLong(byte[] bytes, int index)
  7. bytesToLong(byte[] bytes, int off)
  8. bytesToLong(byte[] bytes, int off, boolean bigEndian)
  9. bytesToLong(byte[] data)