Here you can find the source of intToByteArray(int input)
Parameter | Description |
---|---|
input | The log to convert |
public static byte[] intToByteArray(int input)
//package com.java2s; public class Main { /**/*from w w w.j a v a 2 s .c o m*/ * Utility method for converting a int into a byte[] * * @param input The log to convert * @return a byte[] representation */ public static byte[] intToByteArray(int input) { byte[] output = new byte[4]; intToByteArray(input, output, 0); return output; } /** * Utility method for converting a int into a byte[] * * @param input The log to convert * @return a byte[] representation */ public static void intToByteArray(int input, byte[] output, int offset) { output[offset + 0] = (byte) (0xFF & (input >> 24)); output[offset + 1] = (byte) (0xFF & (input >> 16)); output[offset + 2] = (byte) (0xFF & (input >> 8)); output[offset + 3] = (byte) (0xFF & input); } }