Here you can find the source of toByteArray(long value)
public static byte[] toByteArray(long value)
//package com.java2s; /*/*ww w.j a v a 2 s . co m*/ * Copyright (c) 2015, Antonio Gabriel Mu?oz Conejo <antoniogmc at gmail dot com> * Distributed under the terms of the MIT License */ public class Main { public static byte[] toByteArray(long value) { byte[] b = new byte[Long.BYTES]; for (int i = 0; i < b.length; ++i) { b[i] = (byte) (value >> (Long.BYTES - i - 1 << 3)); } return b; } public static byte[] toByteArray(int value) { byte[] b = new byte[Integer.BYTES]; for (int i = 0; i < b.length; ++i) { b[i] = (byte) (value >> (Integer.BYTES - i - 1 << 3)); } return b; } }