Java Integer to Byte Array int32ToByteArr(int val, byte[] arr, int offset)

Here you can find the source of int32ToByteArr(int val, byte[] arr, int offset)

Description

int To Byte Arr

License

Creative Commons License

Declaration

public final static void int32ToByteArr(int val, byte[] arr, int offset) 

Method Source Code

//package com.java2s;
/*******************************************************************
 * DUBwise/*from  ww  w  .j  av  a 2 s .c o  m*/
 * by Marcus -Ligi- Bueschleb 
 * http://ligi.de
 *
 * License:
 *
 *  http://creativecommons.org/licenses/by-nc-sa/2.0/de/ 
 *  (Creative Commons / Non Commercial / Share Alike)
 *  Additionally to the Creative Commons terms it is not allowed
 *  to use this project in _any_ violent manner! 
 *  This explicitly includes that lethal Weapon owning "People" and 
 *  Organisations (e.g. Army & Police) 
 *  are not allowed to use this Project!
 *
 **********************************************************************/

public class Main {
    public final static void int32ToByteArr(int val, byte[] arr, int offset) {
        arr[offset] = (byte) ((0xFF) & (val));
        arr[offset + 1] = (byte) ((0xFF) & (val >> 8));
        arr[offset + 2] = (byte) ((0xFF) & (val >> 16));
        arr[offset + 3] = (byte) ((0xFF) & (val >> 24));
    }
}

Related

  1. int2bytes(int value, byte[] bytes, int off)
  2. int2bytes(int... numbers)
  3. int2bytes2(int src, byte[] dest)
  4. int32ToArray(int data)
  5. int32ToArrayInPlace(int data, byte[] buffer, int offset)
  6. int32ToByteArray(int a)
  7. int32toByteArray(int i)
  8. int32ToByteArray(int integer)
  9. int32ToByteArray(int value)