Java Convert via ByteBuffer longToByteArray(long value)

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

Description

long To Byte Array

License

Open Source License

Declaration

public static byte[] longToByteArray(long value) 

Method Source Code

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

import java.nio.ByteBuffer;
import java.nio.LongBuffer;

public class Main {
    public static byte[] longToByteArray(long value) {
        byte[] byteArray = new byte[8];
        ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray);
        LongBuffer longBuffer = byteBuffer.asLongBuffer();
        longBuffer.put(0, value);/*from   ww w.j  a v  a  2  s.c o m*/
        return byteArray;
    }
}

Related

  1. longFromBytes(byte[] array)
  2. longFromBytes(byte[] value)
  3. longTo4ByteArray(long n)
  4. longToByteArray(long l)
  5. longToByteArray(long value)
  6. longToByteArray(long[] array)
  7. longToBytes(final long value)
  8. longToBytes(long aLong)
  9. longToBytes(long l)