Here you can find the source of fromLong(long value, int numBytes)
public static byte[] fromLong(long value, int numBytes)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] fromLong(long value, int numBytes) { long mask = 0xFF; byte[] res = new byte[numBytes]; for (int i = 0; i < numBytes; i++) { res[i] = (byte) (value & mask); value = value >> 8;//from w w w . j ava2 s. c o m } return res; } }