Here you can find the source of long2byteArray(long k, byte b[], int off)
public static void long2byteArray(long k, byte b[], int off)
//package com.java2s; //License from project: Open Source License public class Main { public final static int LONG_BYTES = 8; public static void long2byteArray(long k, byte b[], int off) { int j;/*from w ww . ja v a 2 s . com*/ j = b.length; if (b == null || j <= off) { return; } j -= off; if (j > LONG_BYTES) { j = LONG_BYTES; } switch (j) { case 8: b[off + 7] = (byte) ((k >> 56) & 0x0ff); case 7: b[off + 6] = (byte) ((k >> 48) & 0x0ff); case 6: b[off + 5] = (byte) ((k >> 40) & 0x0ff); case 5: b[off + 4] = (byte) ((k >> 32) & 0x0ff); case 4: b[off + 3] = (byte) ((k >> 24) & 0x0ff); case 3: b[off + 2] = (byte) ((k >> 16) & 0x0ff); case 2: b[off + 1] = (byte) ((k >> 8) & 0x0ff); case 1: b[off] = (byte) (k & 0x0ff); } } }