Java Long to Byte longToByte8(long value)

Here you can find the source of longToByte8(long value)

Description

Method converting long into byte array.

License

Open Source License

Parameter

Parameter Description
number The int value to be converted.

Declaration

public static byte[] longToByte8(long value) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w ww .j  a  v  a  2s  . c o m*/
    *
    * Method converting long into byte array.
    *
    * @param number The int value to be converted.
    *
    */
    public static byte[] longToByte8(long value) {
        long tmp_num = value;
        byte[] byte8 = new byte[8];

        for (int i = byte8.length - 1; i > -1; i--) {
            byte8[i] = (byte) (tmp_num & 0xff);
            tmp_num = tmp_num >> 8;
        }

        return byte8;
    }
}

Related

  1. longToByte(long l)
  2. longToByte(long number)
  3. longToByte(long value)
  4. longToByte(long x)
  5. longToByte(long[] values)