Here you can find the source of toLong(byte... b)
public static long toLong(byte... b)
//package com.java2s; /**/*from w ww . jav a 2 s.c om*/ * License * * Licensed under the GNU GPL v3 * http://www.gnu.org/licenses/gpl.html * */ public class Main { public static long toLong(byte... b) { long l = 0; int len = b.length; for (int i = 0; i < len && i < 8; i++) { l = (long) l << 8 | byte2UnsignInt(b[i]); } return l; } public static int byte2UnsignInt(byte b) { if (b >> 1 == b >>> 1) return b; else return 256 + b; } }