Here you can find the source of intToByteArray(int a)
Parameter | Description |
---|---|
a | int. |
public static byte[] intToByteArray(int a)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w.jav a 2s . com * Returns four bytes represented by int. * * @param a int. * @return Four bytes representd by int. */ public static byte[] intToByteArray(int a) { return new byte[] { (byte) ((a >> 24) & 0xFF), (byte) ((a >> 16) & 0xFF), (byte) ((a >> 8) & 0xFF), (byte) (a & 0xFF) }; } }