Here you can find the source of long2bytes(long v, int len)
public static byte[] long2bytes(long v, int len)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] long2bytes(long v, int len) { byte[] b = new byte[len]; for (int i = 7; i > 0 && i > (8 - len); i--) { b[i - (8 - len)] = (byte) (v >>> (56 - (i * 8))); }/*w ww . j a va 2s .com*/ return b; } public static byte[] long2bytes(long v) { return long2bytes(v, 8); } }