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;
/**//from  www . j a  v a2  s  . co m
 * @(#)ByteUtils.java, 2013-2-24.
 * 
 * Copyright 2013 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {

    public static int toInt(byte[] b) {
        return (((((int) b[3]) & 0xFF)) | ((((int) b[2]) & 0xFF) << 8) | ((((int) b[1]) & 0xFF) << 16)
                | ((((int) b[0]) & 0xFF) << 24));
    }

    public static int toInt(byte[] b, int offset) {
        return (((((int) b[3 + offset]) & 0xFF)) | ((((int) b[2 + offset]) & 0xFF) << 8)
                | ((((int) b[1 + offset]) & 0xFF) << 16) | ((((int) b[offset]) & 0xFF) << 24));
    }
}

Related

  1. toInt(byte value)
  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)