Here you can find the source of intToBytes(int i)
public static byte[] intToBytes(int i)
//package com.java2s; /*/* w w w .j a v a 2s . com*/ * @(#)ByteConvertUtil.java V0.0.1 2015-2-3, ????1:37:07 * * Copyright 2015 www.ifood517.com. All rights reserved. * www.ifood517.com PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static byte[] intToBytes(int i) { byte[] intBytes = new byte[4]; intBytes[0] = (byte) (i >> 24); intBytes[1] = (byte) (i >> 16); intBytes[2] = (byte) (i >> 8); intBytes[3] = (byte) (i >> 0); return intBytes; } public static byte[] intToBytes(int i, byte[] data, int index) { data[index] = (byte) (i >> 24); data[index + 1] = (byte) (i >> 16); data[index + 2] = (byte) (i >> 8); data[index + 3] = (byte) (i >> 0); return data; } }