Here you can find the source of fromInt(int input)
Parameter | Description |
---|---|
input | An int to convert to a byte array. |
public static byte[] fromInt(int input)
//package com.java2s; //License from project: BSD License public class Main { /**//from www . j av a2 s. co m * Returns a byte array containing 4 network byte-ordered bytes representing the * given {@code int}. * * @param input An {@code int} to convert to a byte array. * @return A byte array representation of an {@code int} in network byte order * (i.e., big-endian order). */ public static byte[] fromInt(int input) { byte[] output = new byte[4]; output[0] = (byte) (input >> 24); output[1] = (byte) (input >> 16); output[2] = (byte) (input >> 8); output[3] = (byte) input; return output; } }