Java Byte Array to Int byte2int(int[] output, byte[] input, int ioff, int len)

Here you can find the source of byte2int(int[] output, byte[] input, int ioff, int len)

Description

Byte2ints input (bytes) into output (int).

License

Open Source License

Declaration

final static void byte2int(int[] output, byte[] input, int ioff, int len) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w w w  . j ava 2  s  .  c  om
     * Byte2ints input (bytes) into output (int). 
     * Assumes len is a multiple of 4.
     */
    final static void byte2int(int[] output, byte[] input, int ioff, int len) {
        int i = 0;
        for (int j = ioff; j < (ioff + len); j += 4) {
            // This code doesn't work.  
            // Well yes it does, *NOW* as I mask each byte with 0xff.
            // Took me the longest time to figure this out.
            output[i] = (input[j + 0] & 0xff)
                    | ((input[j + 1] & 0xff) << 8)
                    | ((input[j + 2] & 0xff) << 16)
                    | ((input[j + 3] & 0xff) << 24);
            i++;
        }
    }
}

Related

  1. bufferToInt(byte[] ioBuffer)
  2. byte2int(byte b[], int offset)
  3. byte2Int(byte bytes[])
  4. byte2Int(byte[] b)
  5. byte2int(final byte[] arr)
  6. byte2int2(byte[] src, int height, int width)
  7. byte2intarr(byte[] in)
  8. byte2intArray(byte[] b)
  9. bytes2int(byte value1, byte value2)