Java Integer to Byte Array integerToBytes(int x)

Here you can find the source of integerToBytes(int x)

Description

integer To Bytes

License

Open Source License

Declaration

public static byte[] integerToBytes(int x) 

Method Source Code

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

public class Main {
    public static byte[] integerToBytes(int x) {
        byte[] b = new byte[4];
        for (int i = 0; i < 4; ++i) {
            b[i] = (byte) (x >> (4 - i - 1 << 3));
        }//from   ww w  . j av  a  2  s  .c o  m
        return b;
    }
}

Related

  1. integerToByteArray(int value)
  2. IntegerToBytes(int i, byte[] dst, int offset)
  3. integerToBytes(int v, byte[] b)
  4. integerToBytes(int v, byte[] b)
  5. integerToBytes(int value)
  6. intTo2Bytes(int x)
  7. intTo4ByteArray(int value)
  8. intTo4Bytes(int i)
  9. intToByteArray(byte[] bytes, int i)