Java Integer to Byte Array intToByteArray(int bytes)

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

Description

Turn integer into 4 byte array representation

License

Open Source License

Declaration

public static byte[] intToByteArray(int bytes) 

Method Source Code

//package com.java2s;

public class Main {
    /** Turn integer into 4 byte array representation */
    public static byte[] intToByteArray(int bytes) {
        return new byte[] { (byte) ((bytes >>> 24) & 0xff), (byte) ((bytes >>> 16) & 0xff),
                (byte) ((bytes >>> 8) & 0xff), (byte) ((bytes) & 0xff) };
    }/*from ww  w  .  j  a  v a 2 s.c o  m*/
}

Related

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