The following example shows converting a Double to Byte array.
Since a Java Double occupies 8 bytes allocate a ByteBuffer of capacity 8
and write the Double to ByteBuffer. It updates the ByteBuffer with
8 bytes representing the Double. 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 putDouble(double value) Writes eight bytes containing the given double value to this ByteBuffer.
public final byte[] array() Returns the ByteBuffer as byte array.