Here you can find the source of byteToInt(byte[] b)
Parameter | Description |
---|---|
b | a parameter |
public static int byteToInt(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww. j av a 2 s . c o m*/ * @param b * @return */ public static int byteToInt(byte[] b) { int s = 0; final int n256 = 256; final int n2 = 2; for (int i = 0; i < n2; i++) { s = s * n256; if (b[i] >= 0) { s = s + b[i]; } else { s = s + n256 + b[i]; } } return s; } }