Here you can find the source of intToBytes(final int value)
public static byte[] intToBytes(final int value)
//package com.java2s; //License from project: LGPL public class Main { public static byte[] intToBytes(final int value) { final byte[] bytes = new byte[4]; intToBytes(value, bytes, 0);//from w ww. j a va2 s. co m return bytes; } public static void intToBytes(final int value, final byte[] bytes, final int index) { assertNotNull("bytes", bytes); if (bytes.length - index < 4) throw new IllegalArgumentException("bytes.length - index < 4"); for (int i = 0; i < 4; ++i) bytes[index + i] = (byte) (value >>> (8 * (4 - 1 - i))); } public static final <T> T assertNotNull(final String name, final T object) { if (object == null) throw new IllegalArgumentException(String.format("%s == null", name)); return object; } }