Here you can find the source of toArray(int value)
public static byte[] toArray(int value)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static byte[] toArray(int value) { ByteBuffer buffer = ByteBuffer.allocate(4); buffer.order(ByteOrder.BIG_ENDIAN); buffer.putInt(value);/* w w w .ja va 2 s .c o m*/ buffer.flip(); return buffer.array(); } }