Here you can find the source of intToByteArray(int a)
Parameter | Description |
---|---|
a | int to convert. |
public static byte[] intToByteArray(int a)
//package com.java2s; public class Main { /**/* w ww . jav a2 s .c o m*/ * Converts an int to a 4 byte array. * * @param a int to convert. * @return byte array constructed from the passed int. */ public static byte[] intToByteArray(int a) { byte[] ret = new byte[4]; ret[3] = (byte) (a & 0xFF); ret[2] = (byte) ((a >> 8) & 0xFF); ret[1] = (byte) ((a >> 16) & 0xFF); ret[0] = (byte) ((a >> 24) & 0xFF); return ret; } }