Java Integer Create toInt(final byte[] data)

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

Description

Converts the big-endian representation of a 32-bit integer to the equivalent integer value.

License

Open Source License

Parameter

Parameter Description
data 4-byte array in big-endian format.

Return

Long integer value.

Declaration

public static int toInt(final byte[] data) 

Method Source Code

//package com.java2s;
/* See LICENSE for licensing and NOTICE for copyright. */

public class Main {
    /**/*ww w.  ja va2  s  .com*/
     * Converts the big-endian representation of a 32-bit integer to the
     * equivalent integer value.
     *
     * @param  data  4-byte array in big-endian format.
     *
     * @return  Long integer value.
     */
    public static int toInt(final byte[] data) {
        return (data[0] << 24) | ((data[1] & 0xff) << 16) | ((data[2] & 0xff) << 8) | (data[3] & 0xff);
    }
}

Related

  1. toInt(final byte b)
  2. toInt(final byte b)
  3. toInt(final byte[] buffer, final int offset, final int length)
  4. toInt(final byte[] bytes, final int offset)
  5. toInt(final byte[] bytes, final int offset)
  6. toInt(final byte[] inputBytes, int offset)
  7. toInt(final byte[] pBytes)
  8. toInt(final Double value)
  9. toInt(final double[] a, final int len)