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) {

        int mask = 0xff;
        int temp = 0;
        int n = 0;
        for (int i = 0; i < b.length; i++) {
            n <<= 8;//from  w ww .  j  av a  2 s  . c om
            temp = b[i] & mask;
            n |= temp;
        }
        return n;
    }
}

Related

  1. bytesToInt(byte[] array, int offset)
  2. bytesToInt(byte[] b)
  3. bytesToInt(byte[] b)
  4. bytesToInt(byte[] b)
  5. bytesToInt(byte[] b)
  6. bytesToInt(byte[] b, int i)
  7. bytesToInt(byte[] b, int offset)
  8. bytesToInt(byte[] b, int offset)
  9. bytesToInt(byte[] buf, int offset)