Here you can find the source of bytesToInteger(byte[] b)
Parameter | Description |
---|---|
bytes | a parameter |
public final static int bytesToInteger(byte[] b)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004 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://from ww w .j a va2 s. com * 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); } }