Here you can find the source of toLong(byte[] bytes)
public static long toLong(byte[] bytes)
//package com.java2s; /**//from ww w .j ava 2s .co m * Copyright 2012-2013 Johns Hopkins University HLTCOE. All rights reserved. * This software is released under the 2-clause BSD license. * See LICENSE in the project root directory. */ public class Main { public static long toLong(byte[] bytes) { assert (bytes.length >= 8); return ((0xffL & bytes[0]) << 56 | (0xffL & bytes[1]) << 48 | (0xffL & bytes[2]) << 40 | (0xffL & bytes[3]) << 32 | (0xffL & bytes[4]) << 24 | (0xffL & bytes[5]) << 16 | (0xffL & bytes[6]) << 8 | (0xffL & bytes[7]) << 0); } public static long toLong(byte[] bytes, int offset) { assert (bytes.length >= (8 + offset)); return ((0xffL & bytes[0 + offset]) << 56 | (0xffL & bytes[1 + offset]) << 48 | (0xffL & bytes[2 + offset]) << 40 | (0xffL & bytes[3 + offset]) << 32 | (0xffL & bytes[4 + offset]) << 24 | (0xffL & bytes[5 + offset]) << 16 | (0xffL & bytes[6 + offset]) << 8 | (0xffL & bytes[7 + offset]) << 0); } }