Here you can find the source of longToByteArray(long number)
Parameter | Description |
---|---|
number | a parameter |
public static byte[] longToByteArray(long number)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w . ja v a2 s . c om * long to byte array,byte[8] * * @param number * @return byte[] */ public static byte[] longToByteArray(long number) { byte[] byteArray = new byte[8]; byteArray[7] = (byte) (number & 0xff); byteArray[6] = (byte) (number >> 8 & 0xff); byteArray[5] = (byte) (number >> 16 & 0xff); byteArray[4] = (byte) (number >> 24 & 0xff); byteArray[3] = (byte) (number >> 32 & 0xff); byteArray[2] = (byte) (number >> 40 & 0xff); byteArray[1] = (byte) (number >> 48 & 0xff); byteArray[0] = (byte) (number >> 56 & 0xff); return byteArray; } }