Android examples for java.lang:array convert
convert int to byte array via ByteBuffer
import java.nio.ByteBuffer; public class Main { /**// w w w. java2 s. c o m * convert int to byte array * * @param value * integer value * @return byte array */ public static byte[] convertIntToByte(int value) { byte[] temp = new byte[4]; byte[] result = ByteBuffer.allocate(4).putInt(value).array(); temp[0] = result[3]; temp[1] = result[2]; temp[2] = result[1]; temp[3] = result[0]; return temp; } }