Here you can find the source of longToBytes(long l, byte[] result)
public static byte[] longToBytes(long l, byte[] result)
//package com.java2s; /* //from w ww. ja v a 2 s.co m * Copyright (c) 2014 RobotsByTheC. All rights reserved. * * Open Source Software - may be modified and shared by FRC teams. The code must * be accompanied by the BSD license file in the root directory of the project. */ public class Main { public static byte[] longToBytes(long i) { byte[] result = new byte[8]; longToBytes(i, result); return result; } public static byte[] longToBytes(long l, byte[] result) { for (int i = Long.BYTES - 1; i >= 0; i--) { result[i] = (byte) (l & 0xFF); l >>= Byte.SIZE; } return result; } }