Here you can find the source of longToBytes(long x)
public static byte[] longToBytes(long x)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] longToBytes(long x) { byte[] payload = ByteBuffer.allocate(8).putLong(x).array(); return payload; }/*www . ja v a2s . co m*/ }