Here you can find the source of longToBytes(long aLong)
Parameter | Description |
---|---|
aLong | A long. |
public static byte[] longToBytes(long aLong)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { /**/*from www . ja v a 2s .c om*/ * Convert a long to 8 bytes. * * @param aLong A long. * @return A 2's compliment byte representation of the long. */ public static byte[] longToBytes(long aLong) { return ByteBuffer.allocate(8).putLong(aLong).array(); } }