Here you can find the source of toByteArray(int in, int size)
public static byte[] toByteArray(int in, int size)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] toByteArray(int in, int size) { byte[] bytes = new byte[size]; for (int i = size - 1; i >= 0; i--) { bytes[(size - 1) - i] = (byte) (in >>> 8 * i); }//from ww w. ja va2 s . co m return bytes; } public static byte[] toByteArray(int value) { return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; } }