Here you can find the source of intToBytes(final int x)
Parameter | Description |
---|---|
x | The int. |
public static byte[] intToBytes(final int x)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**/*www . j a va 2 s.c om*/ * Converts an int value into an array of 4 bytes. * * @param x The int. * @return The bytes. */ public static byte[] intToBytes(final int x) { final ByteBuffer buffer = ByteBuffer.allocate(4); buffer.putInt(x); return buffer.array(); } }