Here you can find the source of intToByte(int i)
Parameter | Description |
---|---|
i | Integer value to convert |
public static byte[] intToByte(int i)
//package com.java2s; public class Main { /**/*w ww .j av a 2 s . c o m*/ * Converts a given integer value to a byte array * * @param i * Integer value to convert * @return Byte array */ public static byte[] intToByte(int i) { final byte[] b = new byte[4]; for (int j = 3; j >= 0; j--) { b[j] = (byte) (i & 0xFF); i >>= 8; } return b; } }