Here you can find the source of longToBytes(byte[] arr, int offset, long num)
public static int longToBytes(byte[] arr, int offset, long num)
//package com.java2s; //License from project: Open Source License public class Main { public static int longToBytes(byte[] arr, int offset, long num) { arr[offset + 0] = (byte) (num >> 56); arr[offset + 1] = (byte) (num >> 48); arr[offset + 2] = (byte) (num >> 40); arr[offset + 3] = (byte) (num >> 32); arr[offset + 4] = (byte) (num >> 24); arr[offset + 5] = (byte) (num >> 16); arr[offset + 6] = (byte) (num >> 8); arr[offset + 7] = (byte) (num >> 0); return 8; }// w ww . ja v a 2s . c o m }