Here you can find the source of intToBytes(final int number)
public static byte[] intToBytes(final int number)
//package com.java2s; public class Main { /** TODO: Documentation */ public static byte[] intToBytes(final int number) { return new byte[] { (byte) (number >> 24 & 0xFF), (byte) (number >> 16 & 0xFF), (byte) (number >> 8 & 0xFF), (byte) (number & 0xFF) }; }/*from w w w. j a v a2 s .c om*/ /** TODO: Documentation */ public static byte[] intToBytes(final int number, final int arrayLength) { final byte[] bytes = new byte[arrayLength]; int shifted = arrayLength * 8 - 8; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) (number >> shifted & 0xFF); shifted -= 8; } return bytes; } }