Java tutorial
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static long bytesToLong(byte[] bytes) { ByteBuffer buffer = ByteBuffer.allocate(8); reverseArray(bytes); buffer.put(bytes, 0, bytes.length); buffer.flip();// need flip return buffer.getLong(); } private static void reverseArray(byte[] a) { int i = 0, n = a.length - 1; while (n > 2 * i) { byte x = a[i]; a[i] = a[n - i]; a[n - i] = x; i++; } } }