Here you can find the source of longToByteArray(final long value, final int size)
Parameter | Description |
---|---|
value | a parameter |
size | a parameter |
public static byte[] longToByteArray(final long value, final int size)
//package com.java2s; //License from project: Apache License public class Main { /**// w ww . jav a 2 s. co m * * Classname / Method Name : CalculationHelper/longToByteArray() * * @param value * @param size * @return * @Description : Method is used to convert long to byte array */ public static byte[] longToByteArray(final long value, final int size) { final byte[] b = new byte[size]; for (int i = 0; i < size; i++) { final int offset = (b.length - 1 - i) * 8; b[i] = (byte) ((value >> offset) & 0xFF); } return b; } }