Here you can find the source of longToByteArray(final long l)
Parameter | Description |
---|---|
l | Long to convert |
public static byte[] longToByteArray(final long l)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from www . jav a2 s .c o m*/ * Create a byte array from long.<br> * Can be revert with {@link #byteArrayToLong(byte[])} * * @param l * Long to convert * @return Byte array created */ public static byte[] longToByteArray(final long l) { final byte[] array = new byte[8]; array[0] = (byte) ((l >> 56) & 0xFF); array[1] = (byte) ((l >> 48) & 0xFF); array[2] = (byte) ((l >> 40) & 0xFF); array[3] = (byte) ((l >> 32) & 0xFF); array[4] = (byte) ((l >> 24) & 0xFF); array[5] = (byte) ((l >> 16) & 0xFF); array[6] = (byte) ((l >> 8) & 0xFF); array[7] = (byte) (l & 0xFF); return array; } }