Here you can find the source of long2bytes(long num)
public static byte[] long2bytes(long num)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static byte[] long2bytes(long num) { ByteBuffer buffer = ByteBuffer.allocate(8).order( ByteOrder.LITTLE_ENDIAN); buffer.putLong(num);/*from www. ja v a2s.c om*/ return buffer.array(); } }