Here you can find the source of toLong(byte[] buf, int pos)
public static long toLong(byte[] buf, int pos)
//package com.java2s; //License from project: Apache License public class Main { public static long toLong(byte[] buf, int pos) { return ((long) toUnsignedByte(buf, pos + 0)) << 56 + ((long) toUnsignedByte(buf, pos + 1)) << 48 + ((long) toUnsignedByte(buf, pos + 2)) << 40 + ((long) toUnsignedByte(buf, pos + 3)) << 32 + ((long) toUnsignedByte(buf, pos + 4)) << 24 + ((long) toUnsignedByte(buf, pos + 5)) << 16 + ((long) toUnsignedByte(buf, pos + 6)) << 8 + ((long) toUnsignedByte(buf, pos + 7)); }//from w ww. ja va 2 s .c o m public static int toUnsignedByte(byte[] buf, int pos) { int b = buf[pos]; if (b < 0) { b = 256 + b; } return b; } }