Java Byte Array Create toBytes(int i)

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

Description

to Bytes

License

Apache License

Declaration

public static byte[] toBytes(int i) 

Method Source Code

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

public class Main {
    public static byte[] toBytes(int i) {
        byte[] result = new byte[4];
        result[0] = (byte) (i >> 24);
        result[1] = (byte) (i >> 16);
        result[2] = (byte) (i >> 8);
        result[3] = (byte) (i /* >> 0 */);
        return result;
    }//from  w  w  w .j av a  2 s . co m
}

Related

  1. toBytes(final String hexaString)
  2. toBytes(final String str)
  3. toBytes(final String text)
  4. toBytes(int data)
  5. toBytes(int data)
  6. toBytes(int i)
  7. toBytes(int i)
  8. toBytes(int i)
  9. toBytes(int i)