Java Integer to Byte Array int2bytes(int i)

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

Description

intbytes

License

Open Source License

Declaration

public static byte[] int2bytes(int i) 

Method Source Code

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

public class Main {
    public static byte[] int2bytes(int i) {
        byte[] bytes = new byte[4];
        int2bytes(i, bytes, 0);
        return bytes;
    }/*w w  w . j  a v a 2 s .  co m*/

    public static void int2bytes(int i, byte[] bytes, int offset) {
        bytes[offset + 0] = (byte) (i >>> 24);
        bytes[offset + 1] = (byte) (i >>> 16);
        bytes[offset + 2] = (byte) (i >>> 8);
        bytes[offset + 3] = (byte) i;
    }
}

Related

  1. convertIntToBytes(int i)
  2. fromIntToByte(int integer)
  3. fromIntToByteArray(int value)
  4. int2Arr(int var, byte[] arrayBytes, int startIndex)
  5. int2ByteLE(byte[] bytes, int value, int offset)
  6. int2Bytes(int i, byte[] bytes, int offset)
  7. int2bytes(int integer)
  8. int2bytes(int intValue)
  9. int2Bytes(int l, byte[] target, int offset)