Here you can find the source of longToBytes(long n)
public static byte[] longToBytes(long n)
//package com.java2s; public class Main { public static byte[] longToBytes(long n) { return longToBytes(n, new byte[8], 0); }/*from w ww . j av a 2 s. com*/ public static byte[] longToBytes(long n, byte[] arr, int off) { for (int i = 0; i < arr.length; i++) { arr[i + off] = (byte) (n >> 8 * i & 0xFF); } return arr; } }