Source Code : converts an int integer array to a byte array.

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

converts an int integer array to a byte array.

 
/*
 *  Tiled Map Editor, (c) 2004-2006
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Adam Turk <aturk@biggeruniverse.com>
 *  Bjorn Lindeijer <bjorn@lindeijer.nl>
 */


import java.io.File;
import java.io.IOException;

/**
 * Various utility functions.
 */
public class Util
{
    /**
     * This function converts an <code>int</code> integer array to a
     * <code>byte</code> array. Each integer element is broken into 4 bytes and
     * stored in the byte array in litte endian byte order.
     *
     * @param integers an integer array
     * @return a byte array containing the values of the int array. The byte
     *         array is 4x the length of the integer array.
     */
    public static byte[] convertIntegersToBytes (int[] integers) {
        if (integers != null) {
            byte[] outputBytes = new byte[integers.length * 4];

            for(int i = 0, k = 0; i < integers.length; i++) {
                int integerTemp = integers[i];
                for(int j = 0; j < 4; j++, k++) {
                    outputBytes[k] = (byte)((integerTemp >> (8 * j)) & 0xFF);
                }
            }
            return outputBytes;
        } else {
            return null;
        }
    }

 
}

   
  

Thank with us