Java Integer Create toInt(byte[] b)

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

Description

to Int

License

Open Source License

Declaration

public static int toInt(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static int toInt(byte[] b) {
        int value = 0;
        for (int x = 0; x < b.length; x++) {
            value |= b[x] & 0xFF;/*w  w  w  .  ja v  a  2  s  . c  o  m*/
            // if it's the last one, don't shift
            if (x != b.length - 1) {
                value <<= 8;
            }
        }
        return value;
    }

    public static int toInt(byte b) {
        byte[] x = { b };
        return toInt(x);
    }
}

Related

  1. toInt(byte... b)
  2. toInt(byte[] b)
  3. toInt(byte[] b)
  4. toInt(byte[] b)
  5. toInt(byte[] b)
  6. toInt(byte[] b)
  7. toInt(byte[] b)
  8. toInt(byte[] b)
  9. toInt(byte[] b)