Here you can find the source of bytes2Int(byte[] bytes, int offset)
public static int bytes2Int(byte[] bytes, int offset) throws Exception
//package com.java2s; //License from project: Open Source License public class Main { public static int bytes2Int(byte[] bytes, int offset) throws Exception { if (bytes == null || bytes.length - offset < 4) throw new Exception("bytes==null||bytes.length-offset<4"); int value = 0; for (int i = 0; i < 4; i++) { int shift = (i) * 8; value += (bytes[i + offset] & 0x000000FF) << shift; }//from w w w .j ava 2 s.co m return value; } public static int bytes2Int(byte[] bytes) throws Exception { return bytes2Int(bytes, 0); } }