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

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

Description

Converts a byte array to a representative int

License

Open Source License

Parameter

Parameter Description
b byte array to convert

Return

representative int

Declaration

public static int bytesToInt(byte[] b) 

Method Source Code

//package com.java2s;
//    it under the terms of the GNU Lesser General Public License as published

public class Main {
    /**/*from w w  w.  jav a  2s.  c o  m*/
     * Converts a byte array to a representative int
     * @param b byte array to convert
     * @return representative int
     */
    public static int bytesToInt(byte[] b) {
        return ((b[0] << 24) & 0xff000000) | ((b[1] << 16) & 0xff0000) | ((b[2] << 8) & 0xff00) | (b[3] & 0xff);
    }
}

Related

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