Java Integer to Byte Array intToByteArray(int i)

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

Description

Convert from one int to a byte array

License

Open Source License

Parameter

Parameter Description
i the integer

Declaration

public static final byte[] intToByteArray(int i) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  www.j  a  v  a  2s . c o  m
     * Convert from one int to a byte array
     * 
     * @param i the integer
     */
    public static final byte[] intToByteArray(int i) {
        return new byte[] { (byte) (i >> 24), (byte) (i >> 16),
                (byte) (i >> 8), (byte) i };
    }
}

Related

  1. intToByteArray(final int x, final byte[] dst, final int offset)
  2. intToByteArray(int a)
  3. intToByteArray(int a)
  4. intToByteArray(int bytes)
  5. intToByteArray(int data)
  6. intToByteArray(int i)
  7. intToByteArray(int input)
  8. intToByteArray(int integer)
  9. intToByteArray(int integer)