Here you can find the source of byteArrayToInt(byte[] b)
Parameter | Description |
---|---|
b | byte array to convert. |
public static int byteArrayToInt(byte[] b)
//package com.java2s; public class Main { /**/*from w w w. j a va 2 s .c om*/ * Converts a 4 byte array to an int. * * @param b byte array to convert. * @return int constructed from the passed byte[]. */ public static int byteArrayToInt(byte[] b) { int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i] & 0xFF) << shift; } return value; } }