Java Integer to Byte Array int2Bytes(int num)

Here you can find the source of int2Bytes(int num)

Description

Big Endian

License

Apache License

Parameter

Parameter Description
num a parameter

Declaration

static byte[] int2Bytes(int num) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  w w  w.  j  a  va2  s  . c o m
     * Big Endian
     *
     * @param num
     * @return
     */
    static byte[] int2Bytes(int num) {
        byte[] bytes = new byte[4];
        for (int i = 0; i < 4; i++) {
            bytes[3 - i] = (byte) (num >>> 8 * i);
        }
        return bytes;
    }
}

Related

  1. int2bytes(int intValue)
  2. int2Bytes(int l, byte[] target, int offset)
  3. int2Bytes(int n, byte[] dst, int start)
  4. int2Bytes(int num)
  5. int2bytes(int num)
  6. int2bytes(int num)
  7. int2bytes(int num, int len)
  8. int2bytes(int v)
  9. int2bytes(int val, byte[] bytes, int offset, boolean bigEndian)