Here you can find the source of toLong(byte[] bytes)
public static long toLong(byte[] bytes)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Shuichi Miura.// w w w. ja v a 2s .c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Shuichi Miura - initial API and implementation ******************************************************************************/ public class Main { public static long toLong(byte[] bytes) { return ((long) bytes[7] & 255L) + (((long) bytes[6] & 255L) << 8) + (((long) bytes[5] & 255L) << 16) + (((long) bytes[4] & 255L) << 24) + (((long) bytes[3] & 255L) << 32) + (((long) bytes[2] & 255L) << 40) + (((long) bytes[1] & 255L) << 48) + (((long) bytes[0] & 255L) << 56); } }