Here you can find the source of toBytes(long l)
public static byte[] toBytes(long l)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static byte[] toBytes(long l) { ByteBuffer bb = ByteBuffer.allocate(Long.BYTES); bb.putLong(l);//from w w w. j a v a 2 s . c o m return bb.array(); } }