Here you can find the source of bytes2long(byte[] bytes, boolean bigEndian)
public static long bytes2long(byte[] bytes, boolean bigEndian)
//package com.java2s; //License from project: Apache License public class Main { public static long bytes2long(byte[] bytes, boolean bigEndian) { return bytes2long(bytes, 0, bigEndian); }/*from w ww . j av a2 s . co m*/ public static long bytes2long(byte[] bytes, int offset, boolean bigEndian) { long val = 0; if (bigEndian) { for (int i = 0; i < 8; i++) { val |= (((long) bytes[i + offset]) & 0xffL) << ((7 - i) * 8); } } else { for (int i = 0; i < 8; i++) { val |= (((long) bytes[i + offset]) & 0xffL) << (i * 8); } } return val; } }