Android Int to Byte Array Convert IntToByte(int i)

Here you can find the source of IntToByte(int i)

Description

Int To Byte

Declaration

public static byte[] IntToByte(int i) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] IntToByte(int i) {
        byte[] result = new byte[4];
        result[0] = (byte) ((i >> 24) & 0xFF);
        result[1] = (byte) ((i >> 16) & 0xFF);
        result[2] = (byte) ((i >> 8) & 0xFF);
        result[3] = (byte) (i & 0xFF);
        return result;
    }//from   w w  w  .  jav  a2  s .c o m
}

Related

  1. toBytes(int value, byte[] dest, int destPos)
  2. getBytes(int data)
  3. putInt(byte[] bb, int x, int index)
  4. putInt(byte[] bb, int x, int index)
  5. int2bytes(int val)
  6. uInt16ToBytesBI(int value)
  7. uInt16ToBytesBI(int value, byte[] buffer, int startIndex)
  8. uInt16ToBytesLI(int value)
  9. uInt16ToBytesLI(int value, byte[] buffer, int startIndex)