Java tutorial
//package com.java2s; public class Main { public static int bytesToInt(byte[] inBytes, int offset) { if (inBytes.length - offset < 4) { throw new IllegalArgumentException(inBytes.length + " " + offset); } return inBytes[offset + 3] & 0xFF | (inBytes[offset + 2] & 0xFF) << 8 | (inBytes[offset + 1] & 0xFF) << 16 | (inBytes[offset] & 0xFF) << 24; } public static int bytesToInt(byte[] inBytes) { return bytesToInt(inBytes, 0); } }