Here you can find the source of intToByteArray(int value)
Parameter | Description |
---|---|
value | The value |
public static byte[] intToByteArray(int value)
//package com.java2s; public class Main { /** Convert the specified int to a 4 byte array. /*from ww w.j a va 2s. c o m*/ @param value The value @return The byte array */ public static byte[] intToByteArray(int value) { byte[] b = new byte[4]; for (int i = 0; i < 4; i++) { int offset = (b.length - 1 - i) * 8; b[i] = (byte) ((value >>> offset) & 0xFF); } return b; } }