Here you can find the source of int2bytes(int num, int len)
public static byte[] int2bytes(int num, int len)
//package com.java2s; public class Main { public static byte[] int2bytes(int num, int len) { byte[] b = new byte[len]; for (int i = 0; i < len; i++) { b[i] = (byte) (num >>> ((len - 1 - i) * 8)); }/*from w w w. j a v a 2s .c o m*/ return b; } }