Here you can find the source of int2bytes(int num)
static byte[] int2bytes(int num)
//package com.java2s; //License from project: Open Source License public class Main { static byte[] int2bytes(int num) { byte[] b = new byte[4]; for (int i = 0; i < 4; i++) { b[i] = (byte) (num >>> (24 - i * 8)); }/*from w w w . j a v a2 s .c om*/ for (byte by : b) { System.out.println(by); } return b; } }