Here you can find the source of toInt(byte[] bytes)
public static int toInt(byte[] bytes)
//package com.java2s; /*/*from w ww. ja va2 s.c o m*/ * @(#)BytesHelper.java 2012-8-1 ????10:00:00 * * Copyright (c) 2011-2012 Makersoft.org all rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * */ public class Main { public static int toInt(byte[] bytes) { int result = 0; for (int i = 0; i < 4; i++) { result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; } return result; } public static int toInt(byte[] bytes, int startIndex) { int result = 0; for (int i = startIndex; i < 4; i++) { result = (result << 8) | (bytes[i] & 0xFF); } return result; } }