Here you can find the source of longToByte(long i)
public static byte[] longToByte(long i)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] longToByte(long i) { return numberToByte(i, 8); }/* w w w. j ava 2 s. co m*/ 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)); } return bts; } }