Here you can find the source of bytesToLong(byte[] bytes)
public static long bytesToLong(byte[] bytes)
//package com.java2s; public class Main { public static long bytesToLong(byte[] bytes) { if (bytes == null || bytes.length != 8) return 0x0; // ---------- return (long) ( // (Below) convert to longs before shift because digits // are lost with ints beyond the 32-bit limit (long) (0xff & bytes[0]) << 56 | (long) (0xff & bytes[1]) << 48 | (long) (0xff & bytes[2]) << 40 | (long) (0xff & bytes[3]) << 32 | (long) (0xff & bytes[4]) << 24 | (long) (0xff & bytes[5]) << 16 | (long) (0xff & bytes[6]) << 8 | (long) (0xff & bytes[7]) << 0); }//from w w w . j a va2 s.co m }