Java UUID from uuidFromBytes(byte[] b)

Here you can find the source of uuidFromBytes(byte[] b)

Description

uuid From Bytes

License

Open Source License

Declaration

public static UUID uuidFromBytes(byte[] b) 

Method Source Code


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

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.util.UUID;

public class Main {
    public static UUID uuidFromBytes(byte[] b) {
        if (b.length < 16) {
            throw new IllegalArgumentException("uuid needs at least 16 bytes");
        }/*from  w w w.  ja v  a  2  s .co m*/
        ByteBuffer bb = ByteBuffer.wrap(b);
        bb.flip();
        bb.order(ByteOrder.BIG_ENDIAN);
        return new UUID(bb.getLong(), bb.getLong());
    }
}

Related

  1. UUIDFromBytes(byte[] array)
  2. uuidFromBytes(byte[] bytes)
  3. uuidFromMsftBinary(byte[] uuidMsftBytes)
  4. uuidFromThriftBinary(byte[] uuidThriftBytes)