Here you can find the source of integerToBytes(int x)
public static byte[] integerToBytes(int x)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] integerToBytes(int x) { byte[] b = new byte[4]; for (int i = 0; i < 4; ++i) { b[i] = (byte) (x >> (4 - i - 1 << 3)); }//from ww w . j av a 2 s .c o m return b; } }