Java Byte Array Create toBytes(int i)

Here you can find the source of toBytes(int i)

Description

to Bytes

License

Open Source License

Declaration

public static byte[] toBytes(int i) 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] toBytes(int i) {
        byte[] b = new byte[4];

        b[0] = (byte) (i & 0xff);
        b[1] = (byte) ((i & 0xff00) >> 8);
        b[2] = (byte) ((i & 0xff0000) >> 16);
        b[3] = (byte) ((i & 0xff000000) >> 24);
        return b;
    }/*ww  w. j av  a2s.  c o m*/
}

Related

  1. toBytes(int data)
  2. toBytes(int data)
  3. toBytes(int i)
  4. toBytes(int i)
  5. toBytes(int i)
  6. toBytes(int i)
  7. toBytes(int i)
  8. toBytes(int i)
  9. toBytes(int integer)