Java Long to Byte longToByte(long l)

Here you can find the source of longToByte(long l)

Description

Converts a given long value to a byte array

License

Open Source License

Parameter

Parameter Description
l Long value to convert

Return

Byte array

Declaration

public static byte[] longToByte(long l) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w w .  j  a va  2 s  . c  o m*/
     * Converts a given long value to a byte array
     *
     * @param l
     *            Long value to convert
     * @return Byte array
     */
    public static byte[] longToByte(long l) {
        final byte[] b = new byte[8];
        for (int j = 7; j >= 0; j--) {
            b[j] = (byte) (l & 0xFF);
            l >>= 8;
        }

        return b;
    }
}

Related

  1. longToByte(final long value)
  2. longToByte(long a_value)
  3. longToByte(long i)
  4. longToByte(long i_Value)
  5. longToByte(long l)
  6. longToByte(long l)
  7. longToByte(long number)
  8. longToByte(long value)
  9. longToByte(long x)