Android Big Endian Convert getInt(byte[] data, int i, boolean bigEndian)

Here you can find the source of getInt(byte[] data, int i, boolean bigEndian)

Description

get Int

Declaration

public static int getInt(byte[] data, int i, boolean bigEndian) 

Method Source Code

//package com.java2s;

public class Main {
    public static int getInt(byte[] data, int i, boolean bigEndian) {
        if (bigEndian)
            return ((data[i] << 24) + ((data[i + 1] & 0xff) << 16)
                    + ((data[i + 2] & 0xff) << 8) + (data[i + 3] & 0xff));
        else/*from ww w .jav  a 2 s  .  c o m*/
            return ((data[i + 3] << 24) + ((data[i + 2] & 0xff) << 16)
                    + ((data[i + 1] & 0xff) << 8) + (data[i] & 0xff));
    }
}

Related

  1. toggleIntEndian(byte[] b, int off, int len)
  2. toggleLongEndian(byte[] b)
  3. toggleLongEndian(byte[] b, int off, int len)
  4. toggleShortEndian(byte[] b)
  5. toggleShortEndian(byte[] b, int off, int len)
  6. getShort(byte[] data, int i, boolean bigEndian)
  7. switchEndian(int i)
  8. switchEndian(long l)
  9. switchEndian(short i)