Here you can find the source of longToByteArray(long input)
Parameter | Description |
---|---|
input | The log to convert |
public static byte[] longToByteArray(long input)
//package com.java2s; public class Main { /**/*from w w w .j a v a 2 s. c o m*/ * Utility method for converting a long into a byte[] * * @param input The log to convert * @return a byte[] representation */ public static byte[] longToByteArray(long input) { byte[] output = new byte[8]; longToByteArray(input, output, 0); return output; } /** * Utility method for converting a long into a byte[] * * @param input The log to convert * @return a byte[] representation */ public static void longToByteArray(long input, byte[] output, int offset) { output[offset + 0] = (byte) (0xFF & (input >> 56)); output[offset + 1] = (byte) (0xFF & (input >> 48)); output[offset + 2] = (byte) (0xFF & (input >> 40)); output[offset + 3] = (byte) (0xFF & (input >> 32)); output[offset + 4] = (byte) (0xFF & (input >> 24)); output[offset + 5] = (byte) (0xFF & (input >> 16)); output[offset + 6] = (byte) (0xFF & (input >> 8)); output[offset + 7] = (byte) (0xFF & input); } }