Here you can find the source of bytesToLong(byte[] longBytes)
public static long bytesToLong(byte[] longBytes)
//package com.java2s; /*// w ww .j a va 2 s . com * @(#)ByteConvertUtil.java V0.0.1 2015-2-3, ????1:37:07 * * Copyright 2015 www.ifood517.com. All rights reserved. * www.ifood517.com PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static long bytesToLong(byte[] longBytes) { byte[] data = new byte[8]; System.arraycopy(longBytes, 0, data, 0, 8); int mask = 0xff; long temp = 0; long res = 0; for (int i = 0; i < 8; i++) { res <<= 8; temp = data[i] & mask; res |= temp; } return res; } public static long bytesToLong(byte[] longBytes, int index) { byte[] data = new byte[8]; System.arraycopy(longBytes, index, data, 0, 8); int mask = 0xff; long temp = 0; long res = 0; for (int i = 0; i < 8; i++) { res <<= 8; temp = data[i] & mask; res |= temp; } return res; } }