Java Long to Byte Array longToByteArray(final long v, final byte[] buf, final int offset)

Here you can find the source of longToByteArray(final long v, final byte[] buf, final int offset)

Description

long To Byte Array

License

Apache License

Declaration

public static final void longToByteArray(final long v, final byte[] buf, final int offset) 

Method Source Code

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

public class Main {
    public static final void longToByteArray(final long v, final byte[] buf, final int offset) {
        buf[offset + 0] = (byte) ((v >> 56) & 0xFF);
        buf[offset + 1] = (byte) ((v >> 48) & 0xFF);
        buf[offset + 2] = (byte) ((v >> 40) & 0xFF);
        buf[offset + 3] = (byte) ((v >> 32) & 0xFF);
        buf[offset + 4] = (byte) ((v >> 24) & 0xFF);
        buf[offset + 5] = (byte) ((v >> 16) & 0xFF);
        buf[offset + 6] = (byte) ((v >> 8) & 0xFF);
        buf[offset + 7] = (byte) ((v >> 0) & 0xFF);
    }/*from   w  w  w .  j  a v a  2  s.  c o  m*/
}

Related

  1. long2bytes(long x)
  2. long2bytes(long... numbers)
  3. long2bytesBE(long val, byte[] b, int off)
  4. longToByteArr(long v)
  5. longToByteArray(final long l)
  6. longToByteArray(final long val, final byte[] buf, final int offset)
  7. longToByteArray(final long value, final int size)
  8. longToByteArray(long a, byte[] buf)
  9. longToByteArray(long i64)