Here you can find the source of intToBytes(int i)
Parameter | Description |
---|---|
i | - The integer to convert. |
public static byte[] intToBytes(int i)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . j av a 2s .c o m*/ * Returns a byte array containing the bytes of the given integer in big endian order. * * @param i - The integer to convert. * * @return A byte array containing the 4 bytes of the given integer in big endian order. */ public static byte[] intToBytes(int i) { return new byte[] { (byte) (i >> 24), (byte) (i >> 16 & 0xFF), (byte) (i >> 8 & 0xFF), (byte) (i & 0xFF) }; } }