Here you can find the source of intToByteArray(int number)
Parameter | Description |
---|---|
number | int to be converted |
public static byte[] intToByteArray(int number)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**/* www . j av a 2 s. co m*/ * Returns a int as a byte array. * * @param number int to be converted * @return byte array with size of 4 */ public static byte[] intToByteArray(int number) { return ByteBuffer.allocate(Integer.BYTES).putInt(number).array(); } }