Here you can find the source of longToBytes(long val)
Parameter | Description |
---|---|
val | the long value |
public static byte[] longToBytes(long val)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w. jav a 2 s.c om*/ * Convert long value to byte array. * * @param val the long value * @return the byte array of this value */ public static byte[] longToBytes(long val) { byte[] b = new byte[8]; for (int i = 7; i > 0; i--) { b[i] = (byte) val; val >>>= 8; } b[0] = (byte) val; return b; } }