Here you can find the source of intAsBigEnd(byte[] a, int i, int v)
public static byte[] intAsBigEnd(byte[] a, int i, int v)
//package com.java2s; public class Main { /**/*from ww w . ja v a 2s . c o m*/ * Convert an int value into an array in big-endian format. * \param val The value to be converted. * \returns An array with the value \a val in big-endian format. This * array will have 4 bytes long. **/ public static byte[] intAsBigEnd(int val) { byte[] array = new byte[4]; return intAsBigEnd(array, 0, val); } /** * Convert an int value into an array in big-endian format, copying the * result in the passed array at the point especified. * \param a The array where the converted value should be copied. * \param i The starting point, int the array \a a where the copy should * start. * \param v The value to be converted and copied. * \returns \a a. **/ public static byte[] intAsBigEnd(byte[] a, int i, int v) { a[i + 0] = (byte) (0xFF & (v >> 24)); a[i + 1] = (byte) (0xFF & (v >> 16)); a[i + 2] = (byte) (0xFF & (v >> 8)); a[i + 3] = (byte) (0xFF & v); return a; } }