Java Byte Array Create toByteArray(final int value)

Here you can find the source of toByteArray(final int value)

Description

Method used to convert integer to byet array

License

Apache License

Parameter

Parameter Description
value the value to convert

Return

a byte array

Declaration

public static byte[] toByteArray(final int value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/* w  w w.j  a va 2  s  .com*/
     * Method used to convert integer to byet array
     * 
     * @param value
     *            the value to convert
     * @return a byte array
     */
    public static byte[] toByteArray(final int value) {
        return new byte[] { //
                (byte) (value >> 24), //
                (byte) (value >> 16), //
                (byte) (value >> 8), //
                (byte) value //
        };
    }
}

Related

  1. toByteArray(final char[] array)
  2. toByteArray(final char[] array)
  3. toByteArray(final int i)
  4. toByteArray(final int i)
  5. toByteArray(final int i, final byte[] output, final int offset)
  6. toByteArray(final String bitString)
  7. toByteArray(final String hexString)
  8. toByteArray(int data)
  9. toByteArray(int i)