Java Integer to Byte Array intToBytes(byte[] arr, int offset, int num)

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

Description

int To Bytes

License

Open Source License

Declaration

public static int intToBytes(byte[] arr, int offset, int num) 

Method Source Code

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

public class Main {
    public static final int INT_SIZE = 4;

    public static int intToBytes(byte[] arr, int offset, int num) {
        arr[offset + 0] = (byte) (num >> 24);
        arr[offset + 1] = (byte) (num >> 16);
        arr[offset + 2] = (byte) (num >> 8);
        arr[offset + 3] = (byte) (num >> 0);

        return INT_SIZE;
    }/*from  w  w w .  j  a  v a 2s.c om*/
}

Related

  1. intToByteArray4(int value)
  2. intToByteArrayBE(int data)
  3. intToByteArrayLE(int v)
  4. intToByteLittleEnding(int j)
  5. intToByteMSB(int in)
  6. intToBytes(byte[] bytes, int index, int value)
  7. intToBytes(final int aInt)
  8. intToBytes(final int i)
  9. intToBytes(final int integer, final int bLength)