Java Integer to Byte Array convertIntToBytes(int i)

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

Description

convert Int To Bytes

License

Apache License

Declaration

public static byte[] convertIntToBytes(int i) 

Method Source Code

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

public class Main {
    public static byte[] convertIntToBytes(int i) {
        byte[] b = new byte[4];

        b[0] = (byte) (0xff & i);
        b[1] = (byte) ((0xff00 & i) >> 8);
        b[2] = (byte) ((0xff0000 & i) >> 16);
        b[3] = (byte) ((0xff000000 & i) >> 24);
        return b;
    }//from  w ww. ja  v a2 s . c  o m
}

Related

  1. convertIntegersToBytes(int[] integers)
  2. convertIntegerToByteArray(int value, int bytes, boolean revers)
  3. convertIntToByteArray(int value)
  4. convertIntToByteArray(int value, int numberOfBytes)
  5. convertIntToByteArray(int[] rgb)
  6. fromIntToByte(int integer)
  7. fromIntToByteArray(int value)
  8. int2Arr(int var, byte[] arrayBytes, int startIndex)
  9. int2ByteLE(byte[] bytes, int value, int offset)