Here you can find the source of setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)
Parameter | Description |
---|---|
toPutIn | - the array to put in |
startidx | - start index of the num |
theNumber | - the number |
len | - the number size in bytes. |
public static void setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)
//package com.java2s; public class Main { /**/*from w ww. j a va2s . c om*/ * put number in array (big endian way) * @param toPutIn - the array to put in * @param startidx - start index of the num * @param theNumber - the number * @param len - the number size in bytes. */ public static void setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len) { for (int i = 0; i < len; i++) { long num = (theNumber >> (8 * (len - (i + 1)))) & 0xff; toPutIn[i + startidx] = (byte) num; } } }