Here you can find the source of int2bytes(int val)
public static byte[] int2bytes(int val)
//package com.java2s; public class Main { public static byte[] int2bytes(int val) { byte[] data = new byte[4]; data[0] = (byte) (val & 0xFF); data[1] = (byte) (val >> 8 & 0xFF); data[2] = (byte) (val >> 16 & 0xFF); data[3] = (byte) (val >> 24 & 0xFF); return data; }//from w w w . j a va 2 s . c o m }