Here you can find the source of longToByteArray(long in)
static public byte[] longToByteArray(long in)
//package com.java2s; //License from project: Open Source License public class Main { static public byte[] longToByteArray(long in) { byte[] out = new byte[8]; for (int index = 7; index >= 0; index--) { out[index] = (byte) in; in >>= 8;/*from www.java2 s . c o m*/ } return out; } static public void longToByteArray(long in, byte[] out, int offset) { for (int index = 7; index >= 0; index--) { out[offset + index] = (byte) in; in >>= 8; } } }