Here you can find the source of intArrayToBytes(int[] d)
public static byte[] intArrayToBytes(int[] d)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Oak Ridge National Laboratory. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ public class Main { public static byte[] intArrayToBytes(int[] d) { byte[] r = new byte[d.length * 4]; for (int i = 0; i < d.length; i++) { byte[] s = intToBytes(d[i]); for (int j = 0; j < 4; j++) r[4 * i + j] = s[j];// w w w. j av a 2 s.com } return r; } public static byte[] intToBytes(int v) { byte[] r = new byte[4]; for (int i = 0; i < 4; i++) { r[i] = (byte) ((v >>> (i * 8)) & 0xFF); } return r; } }