Here you can find the source of intToByte4(int number)
Parameter | Description |
---|---|
number | The int value to be converted. |
public static byte[] intToByte4(int number)
//package com.java2s; public class Main { /**//from w w w.ja v a 2 s. co m * * Method converting int into byte array. * * @param number The int value to be converted. * */ public static byte[] intToByte4(int number) { int tmp_num = number; byte[] byte4 = new byte[4]; for (int i = byte4.length - 1; i > -1; i--) { byte4[i] = (byte) (tmp_num & 0xff); tmp_num = tmp_num >> 8; } return byte4; } }