Here you can find the source of longToBytes(long v, final byte[] arr)
Parameter | Description |
---|---|
v | the given long |
arr | a given array of 8 bytes that will be returned with the data |
public static byte[] longToBytes(long v, final byte[] arr)
//package com.java2s; /*//from w w w .java2 s . co m * Copyright 2015-16, Yahoo! Inc. * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. */ public class Main { /** * Returns a Little-Endian byte array extracted from the given long. * @param v the given long * @param arr a given array of 8 bytes that will be returned with the data * @return a Little-Endian byte array extracted from the given long. */ public static byte[] longToBytes(long v, final byte[] arr) { for (int i = 0; i < 8; i++) { arr[i] = (byte) (v & 0XFFL); v >>>= 8; } return arr; } }