Here you can find the source of toInt(byte[] b, int begin_index, int len)
public static int toInt(byte[] b, int begin_index, int len)
//package com.java2s; public class Main { public static int toInt(byte[] b, int begin_index, int len) { byte[] a = subset(b, begin_index, len); int n = 0; if (a == null || a.length == 0) return n; for (int i = 0; i < a.length; i++) { n += ((a[i] & 0xff) << ((a.length - i - 1) * 8)); }//w w w . ja va2 s . c o m return n; } public static byte[] subset(byte[] a, int begin_index, int len) { if (a == null) return null; if (begin_index < 0 || len <= 0 || begin_index >= a.length || len > a.length - begin_index) throw new IllegalArgumentException("Wrong arguments: array length:" + a.length + ", begin index:" + begin_index + ", subset length:" + len); byte[] b = new byte[len]; for (int i = 0; i < len; i++) { b[i] = a[i + begin_index]; } return b; } }