Android Int to Byte Array Convert int2ByteArray(int value)

Here you can find the source of int2ByteArray(int value)

Description

int Byte Array

Declaration

public static byte[] int2ByteArray(int value) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] int2ByteArray(int value) {
        byte[] b = new byte[4];
        for (int i = 0; i < 4; i++) {
            int offset = (b.length - 1 - i) * 8;
            b[i] = (byte) ((value >>> offset) & 0xFF);
        }/* w w  w .  j  av a 2  s  .c  o m*/
        return b;
    }
}

Related

  1. getTwoBytes(int i, byte[] target, int pos)
  2. getFourBytes(int i)
  3. getFourBytes(int i, byte[] target, int pos)
  4. splitInt(int value)
  5. int2Byte(int value)
  6. int2ByteArray1(int value)
  7. int2ByteArray11(int value)
  8. int2ByteArray3(int value)
  9. int2byte(int input)