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