Java tutorial
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static int byteArrayToInt(byte[] bytes) throws IllegalArgumentException { if (bytes.length != (Integer.SIZE / Byte.SIZE)) { throw new IllegalArgumentException("Incorrect array size to convert to an int"); } ByteBuffer buffer = ByteBuffer.wrap(bytes); buffer.order(ByteOrder.BIG_ENDIAN); return buffer.getInt(); } }