Here you can find the source of longToBytes(long l)
public static byte[] longToBytes(long l)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { private static ByteBuffer buffer = ByteBuffer.allocate(8); public static byte[] longToBytes(long l) { buffer.putLong(0, l);//from w w w . j a va 2 s . co m return buffer.array(); } }