Here you can find the source of longToBytes(long v)
public static byte[] longToBytes(long v)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] longToBytes(long v) { byte[] data = new byte[8]; int offset = 0; data[offset++] = (byte) ((v >> 56) & 0xFF); data[offset++] = (byte) ((v >> 48) & 0xFF); data[offset++] = (byte) ((v >> 40) & 0xFF); data[offset++] = (byte) ((v >> 32) & 0xFF); data[offset++] = (byte) ((v >> 24) & 0xFF); data[offset++] = (byte) ((v >> 16) & 0xFF); data[offset++] = (byte) ((v >> 8) & 0xFF); data[offset++] = (byte) (v & 0xFF); return data; }//from w w w . j a va 2s . c o m }