java.util.UUID.nameUUIDFromBytes() Method
Advertisements
Description
The nameUUIDFromBytes(byte[] name) method is used as a static factory to retrieve a type 3 (name based) UUID based on the specified byte array.
Declaration
Following is the declaration for java.util.UUID.nameUUIDFromBytes() method.
public static UUID nameUUIDFromBytes(byte[] name)
Parameters
name--This is a byte array to be used to construct a UUID.
Return Value
The method call returns a UUID generated from the specified array.
Exception
NA
Example
The following example shows the usage of java.util.UUID.nameUUIDFromBytes()
package com.tutorialspoint;
import java.util.*;
public class UUIDDemo {
public static void main(String[] args) {
// creating byte array
byte[] nbyte = {10,20,30};
// creating UUID from byte
UUID uid = UUID.nameUUIDFromBytes(nbyte);
// checking UUID value
System.out.println("UUID value from byte: "+uid);
}
}
Let us compile and run the above program, this will produce the following result.
UUID value from byte: 7f49b84d-0bbc-38e9-a493-718013baace6