Here you can find the source of long2bytes(long val)
public static byte[] long2bytes(long val)
//package com.java2s; public class Main { public static byte[] long2bytes(long val) { byte[] data = new byte[8]; data[0] = (byte) (val & 0xFF); data[1] = (byte) (val >> 8 & 0xFF); data[2] = (byte) (val >> 16 & 0xFF); data[3] = (byte) (val >> 24 & 0xFF); data[4] = (byte) (val >> 32 & 0xFF); data[5] = (byte) (val >> 40 & 0xFF); data[6] = (byte) (val >> 48 & 0xFF); data[7] = (byte) (val >> 56 & 0xFF); return data; }//from ww w . java 2 s. c o m }