Java tutorial
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static int bytesToInt(byte[] bytes) { ByteBuffer buffer = ByteBuffer.allocate(4); reverseArray(bytes); buffer.put(bytes, 0, bytes.length); buffer.flip();// need flip return buffer.getInt(); } 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++; } } }