Here you can find the source of intToBytes(int n)
public static byte[] intToBytes(int n)
//package com.java2s; public class Main { public static byte[] intToBytes(int n) { return intToBytes(n, new byte[4], 0); }/* ww w . j a v a 2 s . c o m*/ public static byte[] intToBytes(int n, byte[] bs, int off) { for (int i = 0; i < 4; i++) { bs[i + off] = (byte) (n >> 8 * i & 0xFF); } return bs; } }