Here you can find the source of bytesToInt(byte[] b, int offset)
public static int bytesToInt(byte[] b, int offset)
//package com.java2s; //License from project: Apache License public class Main { public static int bytesToInt(byte[] b, int offset) { int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i + offset] & 0x000000FF) << shift; }//from www . ja v a 2 s. c om return value; } public static int bytesToInt(byte[] bytes) { return (0xff & bytes[0]) | (0xff00 & (bytes[1] << 8)) | (0xff0000 & (bytes[2] << 16)) | (0xff000000 & (bytes[3] << 24)); } }