Java Integer to Byte Array int2bytes(int num)

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

Description

intbytes

License

Open Source License

Declaration

static byte[] int2bytes(int num) 

Method Source Code

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

public class Main {
    static byte[] int2bytes(int num) {
        byte[] b = new byte[4];
        for (int i = 0; i < 4; i++) {
            b[i] = (byte) (num >>> (24 - i * 8));
        }/*from w w w . j a  v  a2  s  .c om*/
        for (byte by : b) {
            System.out.println(by);
        }
        return b;
    }
}

Related

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