Here you can find the source of longToBytes(long num, byte[] data, int index)
public static byte[] longToBytes(long num, byte[] data, int index)
//package com.java2s; /*/*from ww w . ja v a2 s.c o m*/ * @(#)ByteConvertUtil.java V0.0.1 2015-2-3, ????1:37:07 * * Copyright 2015 www.ifood517.com. All rights reserved. * www.ifood517.com PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static byte[] longToBytes(long num) { byte[] b = new byte[8]; for (int i = 0; i < 8; i++) { b[i] = (byte) (num >> (56 - i * 8)); } return b; } public static byte[] longToBytes(long num, byte[] data, int index) { for (int i = 0; i < 8; i++) { data[index + i] = (byte) (num >> (56 - i * 8)); } return data; } }