Here you can find the source of bytesToInt(byte[] bytes)
Parameter | Description |
---|---|
bytes | - A byte[] containing the bytes to convert. |
public static int bytesToInt(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w. j a v a 2s . com*/ * Converts a byte[] of unsigned bytes in big-endian order to an int. * * @param bytes - A byte[] containing the bytes to convert. * * @return An int containing the equivalent signed value of the given bytes. */ public static int bytesToInt(byte[] bytes) { int i = 0; i |= (bytes[0] & 0xFF) << 24; i |= (bytes[1] & 0xFF) << 16; i |= (bytes[2] & 0xFF) << 8; i |= (bytes[3] & 0xFF); return i; } }