Android Int to Byte Array Convert intToBytes(int n)

Here you can find the source of intToBytes(int n)

Description

int To Bytes

Declaration

public static byte[] intToBytes(int n) 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] intToBytes(int n) {
        byte[] b = new byte[4];
        b[3] = (byte) (n >> 24);
        b[2] = (byte) (n >> 16);
        b[1] = (byte) (n >> 8);
        b[0] = (byte) (n >> 0);
        return b;
    }//from   ww w .  jav  a2  s .c o  m
}

Related

  1. intToByteArray(int a)
  2. intToByteArray(int i)
  3. intToByteArray(int value)
  4. intToBytes(int i)
  5. intToBytes(int in)
  6. intToBytes(int number)
  7. intToBytes(int x)
  8. toBytes(int value)
  9. toBytes(int value, byte[] dest, int destPos)