Java Integer to Byte intToByteArr(int v)

Here you can find the source of intToByteArr(int v)

Description

int To Byte Arr

License

Open Source License

Declaration

public static byte[] intToByteArr(int v) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] intToByteArr(int v) {
        return new byte[] { (byte) (v >>> 24), (byte) (v >>> 16), (byte) (v >>> 8), (byte) (v) };
    }//from w  ww.j  a v a2  s . c  o  m

    public static byte[] intToByteArr(int v, byte[] arr, int position) {
        for (int i = 24; i >= 0; i -= 8) {
            arr[position--] = (byte) (v >>> i);
        }
        return arr;
    }
}

Related

  1. intToByte(int v, byte[] dest)
  2. intToByte(int value)
  3. intToByte(int value)
  4. intToByte(int[] values)
  5. intToByte4(int number)