Here you can find the source of bytesToLong(byte[] bytes)
Parameter | Description |
---|---|
bytes | - A byte[] containing the bytes to convert. |
public static long bytesToLong(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**//w w w. ja va2 s .c o m * Converts a byte[] of unsigned bytes in big-endian order to a long. * * @param bytes - A byte[] containing the bytes to convert. * * @return A long containing the equivalent signed value of the given bytes. */ public static long bytesToLong(byte[] bytes) { long l = 0; l |= (bytes[0] & 0xFFL) << 56; l |= (bytes[1] & 0xFFL) << 48; l |= (bytes[2] & 0xFFL) << 40; l |= (bytes[3] & 0xFFL) << 32; l |= (bytes[4] & 0xFFL) << 24; l |= (bytes[5] & 0xFFL) << 16; l |= (bytes[6] & 0xFFL) << 8; l |= (bytes[7] & 0xFFL); return l; } }