Here you can find the source of intToBytes(int value)
Parameter | Description |
---|---|
value | source integer |
public static byte[] intToBytes(int value)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . j a v a 2s . c o m * Converting int to bytes * * @param value source integer * @return bytes of integer */ public static byte[] intToBytes(int value) { return new byte[] { (byte) (value & 0xFF), (byte) ((value >> 8) & 0xFF), (byte) ((value >> 16) & 0xFF), (byte) ((value >> 24) & 0xFF) }; } }