Java Integer to Byte int2byte(final int i)

Here you can find the source of int2byte(final int i)

Description

Convert int to byte[4]

License

Open Source License

Parameter

Parameter Description
i int

Return

byte[4]

Declaration

public static byte[] int2byte(final int i) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  w w.jav a2  s  .c  o m*/
     * Convert int to byte[4]
     * 
     * @param i
     *            int
     * @return byte[4]
     */
    public static byte[] int2byte(final int i) {
        final byte[] arr = new byte[4];

        arr[0] = (byte) i;
        arr[1] = (byte) (i >>> 8);
        arr[2] = (byte) (i >>> 16);
        arr[3] = (byte) (i >>> 24);

        return arr;
    }
}

Related

  1. asByte(int a)
  2. int2bcdByte(int hRadix10, int lRadix10)
  3. int2bin(byte[] out, int offset, int i)
  4. int2byte(byte[] output, int[] input, int len)
  5. int2byte(int i)
  6. int2Byte(int intValue)
  7. int2byte(int ival, byte b[], int offset)
  8. int2byte(int value)