Here you can find the source of longToBytes(long l)
Parameter | Description |
---|---|
l | - The long to convert |
public static byte[] longToBytes(long l)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j av a 2s. co m * Returns a byte array containing the bytes of the given long in big endian order. * * @param l - The long to convert * * @return A byte array containing the 8 bytes of the given long in big endian order. */ public static byte[] longToBytes(long l) { return new byte[] { (byte) (l >> 56), (byte) (l >> 48), (byte) (l >> 40), (byte) (l >> 32), (byte) (l >> 24), (byte) (l >> 16 & 0xFF), (byte) (l >> 8 & 0xFF), (byte) (l & 0xFF) }; } }