Java Byte Array to Int byte2int(final byte[] arr)

Here you can find the source of byte2int(final byte[] arr)

Description

Convert int to byte[4]

License

Open Source License

Parameter

Parameter Description
arr byte[4]

Return

int

Declaration

public static int byte2int(final byte[] arr) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w  w  w .  ja  v  a  2  s. co m
     * Convert int to byte[4]
     * 
     * @param arr
     *            byte[4]
     * @return int
     */
    public static int byte2int(final byte[] arr) {
        int res = arr[3] & 0xff;

        res = (res << 8) | (arr[2] & 0xff);
        res = (res << 8) | (arr[1] & 0xff);
        res = (res << 8) | (arr[0] & 0xff);

        return res;
    }
}

Related

  1. arr2int(byte[] arr, int start)
  2. bufferToInt(byte[] ioBuffer)
  3. byte2int(byte b[], int offset)
  4. byte2Int(byte bytes[])
  5. byte2Int(byte[] b)
  6. byte2int(int[] output, byte[] input, int ioff, int len)
  7. byte2int2(byte[] src, int height, int width)
  8. byte2intarr(byte[] in)
  9. byte2intArray(byte[] b)