Here you can find the source of intToByte(int number, int byteLength)
public static byte[] intToByte(int number, int byteLength)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] intToByte(int number, int byteLength) { byte[] bLocalArr = new byte[byteLength]; for (int i = 0; (i < 4) && (i < byteLength); i++) { bLocalArr[i] = (byte) (number >> 8 * i & 0xFF); }/* w ww. j av a2s. com*/ return bLocalArr; } public static byte[] intToByte(int number) { int byteLength = 4; byte[] bLocalArr = new byte[byteLength]; for (int i = 0; (i < 4) && (i < byteLength); i++) { bLocalArr[i] = (byte) (number >> 8 * i & 0xFF); } return bLocalArr; } }