Java Convert via ByteBuffer longToBytes(long l)

Here you can find the source of longToBytes(long l)

Description

long To Bytes

License

Open Source License

Declaration

public static byte[] longToBytes(long l) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    private static ByteBuffer buffer = ByteBuffer.allocate(8);

    public static byte[] longToBytes(long l) {
        buffer.putLong(0, l);//from w  w w  .  j a va  2 s . co m
        return buffer.array();
    }
}

Related

  1. longToByteArray(long value)
  2. longToByteArray(long value)
  3. longToByteArray(long[] array)
  4. longToBytes(final long value)
  5. longToBytes(long aLong)
  6. longToBytes(long l, int size)
  7. longToBytes(long x)
  8. longToBytes(long x, byte[] dest, int offset)
  9. longToBytesNoLeadZeroes(long val)