Here you can find the source of toByteArray(int[] intArray)
public static byte[] toByteArray(int[] intArray)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**//from w w w . java 2s .co m * Returns a new byte array using data from the given integer array. */ public static byte[] toByteArray(int[] intArray) { ByteBuffer byteBuffer = ByteBuffer.allocate(intArray.length * 4); byteBuffer.asIntBuffer().put(intArray); return byteBuffer.array(); } }