Java Byte Array to Int bytesToInt(byte[] b)

Here you can find the source of bytesToInt(byte[] b)

Description

bytes To Int

License

Open Source License

Declaration

public static int bytesToInt(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static int bytesToInt(byte[] b) {
        return bytesToInt(b[0], b[1], b[2], b[3]);

    }//  w  w  w .  j a  v a2 s . com

    public static int bytesToInt(byte b1, byte b2, byte b3, byte b4) {
        int answer = 0xFF & b4;
        answer = answer << 8 | (0xFF & b3);
        answer = answer << 8 | (0xFF & b2);
        answer = answer << 8 | (0xFF & b1);
        return answer;

    }
}

Related

  1. bytesToInt(byte b1, byte b2, byte b3, byte b4)
  2. bytesToInt(byte bytes[], int start)
  3. bytesToInt(byte low, byte high)
  4. bytesToInt(byte[] array, int offset)
  5. bytesToInt(byte[] array, int offset)
  6. bytesToInt(byte[] b)
  7. bytesToInt(byte[] b)
  8. bytesToInt(byte[] b)
  9. bytesToInt(byte[] b)