import java.util.UUID; String name = "John Doe"; UUID uuid = UUID.nameUUIDFromBytes(name.getBytes());
import java.util.UUID; import java.nio.file.Files; import java.nio.file.Path; Path filePath = Path.of("example.txt"); byte[] fileBytes = Files.readAllBytes(filePath); UUID uuid = UUID.nameUUIDFromBytes(fileBytes);In this example, the contents of a file are read into a byte array and then passed to the nameUUIDFromBytes method to generate a UUID. The java.util.UUID class is part of the Java SE Library.