Here you can find the source of convertToByteArray(long l)
Parameter | Description |
---|---|
l | the long to convert |
public static byte[] convertToByteArray(long l)
//package com.java2s; public class Main { /**//w w w .ja v a 2s . c o m * Converts the long to a 4 byte array. The long must be non negative. * @param l the long to convert * @return a byte array that is the same as the long */ public static byte[] convertToByteArray(long l) { byte[] b = new byte[4]; b[0] = (byte) (255 & (l >> 24)); b[1] = (byte) (255 & (l >> 16)); b[2] = (byte) (255 & (l >> 8)); b[3] = (byte) (255 & l); return b; } }