Java Integer Array Convert To intsToBytes(int[] a, int aoffset, int len, byte[] b, int boffset)

Here you can find the source of intsToBytes(int[] a, int aoffset, int len, byte[] b, int boffset)

Description

ints To Bytes

License

Open Source License

Declaration

public static final void intsToBytes(int[] a, int aoffset, int len, byte[] b, int boffset) 

Method Source Code

//package com.java2s;
/**/*from w  w w . j a  v  a2  s.c o  m*/
  *         Commmon Internet File System Java API (JCIFS)
  *----------------------------------------------------------------
  *  Copyright (C) 1999  Norbert Hranitzky
  *
  *  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.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  *  General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *  The full copyright text: http://www.gnu.org/copyleft/gpl.html
  *
  *----------------------------------------------------------------
  *  Author: Norbert Hranitzky
  *  Email : norbert.hranitzky@mchp.siemens.de
  *  Web   : http://www.hranitzky.purespace.de
  */

public class Main {
    public static final void intsToBytes(int[] a, int aoffset, int len, byte[] b, int boffset) {

        for (int i = 0; i < len; ++i)
            intToBytes(a[aoffset + i], b, boffset + (i << 2));
    }

    public static final void intToBytes(int a, byte[] b, int bo) {
        b[bo] = (byte) ((a >> 24) & 0xff);
        b[bo + 1] = (byte) ((a >> 16) & 0xff);
        b[bo + 2] = (byte) ((a >> 8) & 0xff);
        b[bo + 3] = (byte) ((a) & 0xff);

    }
}

Related

  1. intArrayToCharArray(int[][] intArray)
  2. intArrayToFloatArray(int[] intArray)
  3. intArrayToIp(final int[] array, final int offset)
  4. intsToByteHighAndLow(int highValue, int lowValue)
  5. intsToBytes(byte[] dst, int dst_offset, int[] src, int src_offset, int length)
  6. intsToBytes(int[] data)
  7. intsToBytes(int[] intArray)
  8. intsToBytes(int[][] ints)
  9. intsToCommaSeparatedString(int[] ints)