Java Convert via ByteBuffer toByteArray(UUID uniqueId)

Here you can find the source of toByteArray(UUID uniqueId)

Description

to Byte Array

License

Open Source License

Declaration

private static byte[] toByteArray(UUID uniqueId) 

Method Source Code

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

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

import java.util.UUID;

public class Main {
    private static byte[] toByteArray(UUID uniqueId) {
        byte[] bytes = new byte[(Long.SIZE / Byte.SIZE) * 2];
        LongBuffer longBuffer = ByteBuffer.wrap(bytes).asLongBuffer();

        longBuffer.put(new long[] { uniqueId.getMostSignificantBits(), uniqueId.getLeastSignificantBits() });
        return bytes;
    }// w ww.  j  a va  2  s.c o  m
}

Related

  1. ToByteArray(long[] data)
  2. toByteArray(ReadableByteChannel channel)
  3. toByteArray(String bits)
  4. ToByteArray(String hexString)
  5. toByteArray(String value)
  6. toByteArray2(String filename)
  7. toByteArray3(String filename)
  8. toByteArrayFromInt(int intValue, boolean shortSize)
  9. toByteArrayFromLong(long longValue)