Here you can find the source of numberToByte(long l, int length)
private static byte[] numberToByte(long l, int length)
//package com.java2s; //License from project: Open Source License public class Main { private static byte[] numberToByte(long l, int length) { byte[] bts = new byte[length]; for (int i = 0; i < length; i++) { bts[i] = (byte) (l >> ((length - i - 1) * 8)); }//from w w w.j a v a 2 s. c o m return bts; } }