Here you can find the source of bytes2int(byte[] bytes, int begin)
Parameter | Description |
---|---|
bytes | a parameter |
begin | the starting index of the integer |
public static int bytes2int(byte[] bytes, int begin)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w .j a v a2s . co m*/ * convert a 4byte-array to an integer * big-endian alignment * @param bytes * @param begin the starting index of the integer */ public static int bytes2int(byte[] bytes, int begin) { int value = 0; int mask = 0x000000FF; for (int i = 0; i < 4; i++) { value <<= 8; value |= mask & bytes[begin + i]; //@debug //System.out.printf("i=%d: val: %08X\n",i,value); } return value; } }