Here you can find the source of bytesToInteger(byte[] b, int off)
public final static int bytesToInteger(byte[] b, int off)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004,2009 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w .j a v a 2 s .co m * Actuate Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Assemble four bytes to an int value, make sure that the passed bytes * length is larger than 4. * * @param bytes * @return int value of bytes */ public final static int bytesToInteger(byte[] b) { assert b.length >= 4; return ((b[0] & 0xFF) << 24) + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF) << 8) + ((b[3] & 0xFF) << 0); } public final static int bytesToInteger(byte[] b, int off) { assert b.length - off >= 4; return ((b[off++] & 0xFF) << 24) + ((b[off++] & 0xFF) << 16) + ((b[off++] & 0xFF) << 8) + ((b[off] & 0xFF) << 0); } }