Java Integer Create toInt(byte... b)

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

Description

to Int

License

GNU General Public License

Declaration

public static int toInt(byte... b) 

Method Source Code

//package com.java2s;
/**//from  w  ww. ja v a  2 s  .c  o  m
 * License
 * 
 * Licensed under the GNU GPL v3
 * http://www.gnu.org/licenses/gpl.html
 * 
 */

public class Main {

    public static int toInt(byte... b) {
        return (int) toLong(b);
    }

    public static long toLong(byte... b) {
        long l = 0;
        int len = b.length;
        for (int i = 0; i < len && i < 8; i++) {
            l = (long) l << 8 | byte2UnsignInt(b[i]);
        }
        return l;
    }

    public static int byte2UnsignInt(byte b) {
        if (b >> 1 == b >>> 1)
            return b;
        else
            return 256 + b;
    }
}

Related

  1. toInt(byte byte3, byte byte2, byte byte1, byte byte0)
  2. toInt(byte in0, byte in1, byte in2, byte in3)
  3. toInt(byte mostSignificant, byte leastSignificant)
  4. toInt(byte src)
  5. toInt(byte value)
  6. toInt(byte... b)
  7. toInt(byte[] b)
  8. toInt(byte[] b)
  9. toInt(byte[] b)