Here you can find the source of longToBytes(long value, byte[] buffer, int bufferStartPosition)
public static void longToBytes(long value, byte[] buffer, int bufferStartPosition)
//package com.java2s; //License from project: Open Source License public class Main { public static void longToBytes(long value, byte[] buffer, int bufferStartPosition) { int endPos = bufferStartPosition + 8; for (int idx = bufferStartPosition; idx < endPos; idx++) { buffer[idx] = (byte) (value & 0xFF); value = value >> 8;// w w w .jav a 2 s . c o m } } }