Here you can find the source of toInt(byte[] bytes, int offset)
Parameter | Description |
---|---|
bytes | the bytes |
offset | the offset |
public static int toInt(byte[] bytes, int offset)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Vladimir Rodionov. All Rights Reserved * * This code is released under the GNU Affero General Public License. * * See: http://www.fsf.org/licensing/licenses/agpl-3.0.html * * VLADIMIR RODIONOV MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * NON-INFRINGEMENT. Vladimir Rodionov SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR * ITS DERIVATIVES./*from w ww . j a v a2 s . c o m*/ * * Author: Vladimir Rodionov * *******************************************************************************/ public class Main { /** * To int. * * @param bytes the bytes * @param offset the offset * @return the int */ public static int toInt(byte[] bytes, int offset) { int l = 0; for (int i = offset; i < offset + 4; i++) { l <<= 8; l ^= bytes[i] & 0xFF; } return l; } }