Here you can find the source of toBytes(int value)
public static byte[] toBytes(int value)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] toBytes(int value) { byte[] result = new byte[4]; for (int idx = 0; idx < 4; idx++) { result[idx] = (byte) (value & 0xFF); value = value >> 8;//from ww w . jav a2s. c o m } return result; } }