Here you can find the source of getByteArrayByLong(long value, int n, boolean isLH)
Parameter | Description |
---|---|
value | a parameter |
n | a parameter |
isLH | a parameter |
public static byte[] getByteArrayByLong(long value, int n, boolean isLH)
//package com.java2s; public class Main { /**//from w ww . ja v a 2 s .c om * get bytes by the long value. l before h after * * @param value * @param n * return bytes length * @return */ public static byte[] getByteArrayByLong(long value, int n) { return getByteArrayByLong(value, n, true); } /** * get bytes by the long value * * @param value * @param n * @param isLH * @return */ public static byte[] getByteArrayByLong(long value, int n, boolean isLH) { byte[] dest = new byte[n]; for (int i = 0; i < n; i++) { dest[i] = (byte) ((value >> ((isLH ? i : n - i - 1) * 8)) & 0xFF); } return dest; } }