Here you can find the source of bytes2Integer(byte[] byteVal)
public static int bytes2Integer(byte[] byteVal)
//package com.java2s; //License from project: Apache License public class Main { public static int bytes2Integer(byte[] byteVal) { int result = 0; for (int i = 0; i < byteVal.length; i++) { int tmpVal = (byteVal[i] << (8 * (3 - i))); switch (i) { case 0: tmpVal = tmpVal & 0xFF000000; break; case 1: tmpVal = tmpVal & 0x00FF0000; break; case 2: tmpVal = tmpVal & 0x0000FF00; break; case 3: tmpVal = tmpVal & 0x000000FF; break; }//from ww w . j av a 2 s . c o m result = result | tmpVal; } return result; } }