The following example shows converting a Long to Byte array.
Since a Java Long occupies 8 bytes allocate a ByteBuffer of capacity 8
and write the Long to ByteBuffer. It updates the ByteBuffer with
8 bytes representing the Long. Finally convert the ByteBuffer to byte array.
java.nio.ByteBuffer
public static ByteBuffer allocate(int capacity) Allocates a new byte buffer of given capacity.
public ByteBuffer putLong(long value) Writes eight bytes containing the given long value to this ByteBuffer.
public final byte[] array() Returns the ByteBuffer as byte array.