Java Long to Byte Array longToByteArray(long in)

Here you can find the source of longToByteArray(long in)

Description

long To Byte Array

License

Open Source License

Declaration

static public byte[] longToByteArray(long in) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static public byte[] longToByteArray(long in) {
        byte[] out = new byte[8];

        for (int index = 7; index >= 0; index--) {
            out[index] = (byte) in;
            in >>= 8;/*from www.java2  s . c o m*/
        }

        return out;
    }

    static public void longToByteArray(long in, byte[] out, int offset) {
        for (int index = 7; index >= 0; index--) {
            out[offset + index] = (byte) in;
            in >>= 8;
        }
    }
}

Related

  1. longToByteArray(final long v, final byte[] buf, final int offset)
  2. longToByteArray(final long val, final byte[] buf, final int offset)
  3. longToByteArray(final long value, final int size)
  4. longToByteArray(long a, byte[] buf)
  5. longToByteArray(long i64)
  6. longToByteArray(long input)
  7. longToByteArray(long l)
  8. longToByteArray(long l)
  9. longToByteArray(long l)