Here you can find the source of longToByteArray(long value)
public static byte[] longToByteArray(long value)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.LongBuffer; public class Main { public static byte[] longToByteArray(long value) { byte[] byteArray = new byte[8]; ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray); LongBuffer longBuffer = byteBuffer.asLongBuffer(); longBuffer.put(0, value);/*from ww w.j a v a 2 s.c o m*/ return byteArray; } }