Java Long Number Convert To fromLong(long input)

Here you can find the source of fromLong(long input)

Description

Returns a byte array containing 8 network byte-ordered bytes representing the given long .

License

BSD License

Parameter

Parameter Description
input The long to convert to a byte array.

Return

A byte array representation of a long .

Declaration

public static byte[] fromLong(long input) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**/*from   ww w. j ava2s.co m*/
     * Returns a byte array containing 8 network byte-ordered bytes representing
     * the given {@code long}.
     *
     * @param input The {@code long} to convert to a {@code byte} array.
     * @return A byte array representation of a {@code long}.
     */
    public static byte[] fromLong(long input) {
        byte[] output = new byte[8];
        output[0] = (byte) (input >> 56);
        output[1] = (byte) (input >> 48);
        output[2] = (byte) (input >> 40);
        output[3] = (byte) (input >> 32);
        output[4] = (byte) (input >> 24);
        output[5] = (byte) (input >> 16);
        output[6] = (byte) (input >> 8);
        output[7] = (byte) input;
        return output;
    }
}

Related

  1. convertLongToCidr(long unsignedIntCidr)
  2. convertLongToDouble(final long[] longs)
  3. convertLongToInt(long l)
  4. convertLongToString(long value)
  5. fromLong(long d)
  6. fromLong(long key)
  7. fromLong(long longValue)
  8. fromLong(long v, int offset, byte[] dest)
  9. fromLong(Long value)