Here you can find the source of toLong(byte[] b)
public static long toLong(byte[] b)
//package com.java2s; /**/*from ww w. ja va 2s. c om*/ * @(#)ByteUtils.java, 2013-2-24. * * Copyright 2013 Netease, Inc. All rights reserved. * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static long toLong(byte[] b) { return ((((long) b[7]) & 0xFF) | ((((long) b[6]) & 0xFF) << 8) | ((((long) b[5]) & 0xFF) << 16) | ((((long) b[4]) & 0xFF) << 24) | ((((long) b[3]) & 0xFF) << 32) | ((((long) b[2]) & 0xFF) << 40) | ((((long) b[1]) & 0xFF) << 48) | ((((long) b[0]) & 0xFF) << 56)); } public static long toLong(byte[] b, int offset) { return ((((long) b[offset + 7]) & 0xFF) | ((((long) b[offset + 6]) & 0xFF) << 8) | ((((long) b[offset + 5]) & 0xFF) << 16) | ((((long) b[offset + 4]) & 0xFF) << 24) | ((((long) b[offset + 3]) & 0xFF) << 32) | ((((long) b[offset + 2]) & 0xFF) << 40) | ((((long) b[offset + 1]) & 0xFF) << 48) | ((((long) b[offset]) & 0xFF) << 56)); } }