Here you can find the source of longToBytes(long val)
public static byte[] longToBytes(long val)
//package com.java2s; public class Main { /** Converts a long {@code val} into an array of bytes. */*from w w w.ja va2s .c om*/ *@return The {@code byte[]} representation of the long value. */ public static byte[] longToBytes(long val) { byte[] byteArr = new byte[8]; for (int i = 0; i < 8; i++) { byte nextByte = (byte) ((val >> i * 8) & 0xff); byteArr[i] = nextByte; } return byteArr; } }