Here you can find the source of toBytes(long value)
Parameter | Description |
---|---|
value | Value. |
public static byte[] toBytes(long value)
//package com.java2s; //License from project: Apache License public class Main { /**// w ww . j a v a 2 s . c o m * Convert long to 4 bytes array. Same as byteValue().<br> * Example:<br> * value:258, result: {0x00, 0x00, 0x01, 0x02}.<br> * @param value Value. * @return Result */ public static byte[] toBytes(long value) { byte[] result = new byte[8]; result[0] = (byte) (value >> 56); result[1] = (byte) (value >> 48); result[2] = (byte) (value >> 40); result[3] = (byte) (value >> 32); result[4] = (byte) (value >> 24); result[5] = (byte) (value >> 16); result[6] = (byte) (value >> 8); result[7] = (byte) value; return result; } }