Here you can find the source of bytesToInt(final byte[] arr)
Parameter | Description |
---|---|
arr | the given byte array |
public static int bytesToInt(final byte[] arr)
//package com.java2s; /*/*from w w w . j av a 2 s.c om*/ * Copyright 2015-16, Yahoo! Inc. * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. */ public class Main { /** * Returns an int extracted from a Little-Endian byte array. * @param arr the given byte array * @return an int extracted from a Little-Endian byte array. */ public static int bytesToInt(final byte[] arr) { int v = 0; for (int i = 0; i < 4; i++) { v |= (arr[i] & 0XFF) << i * 8; } return v; } }