Java tutorial
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.UUID; public class Main { public static final String BASE_UUID_START = "0000"; public static final String BASE_UUID_END = "-0000-1000-8000-00805f9b34fb"; public static byte[] uuidToBytes(String uuidStr) { UUID uuid = stringToUuid(uuidStr); ByteBuffer bb = ByteBuffer.allocate(16); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putLong(uuid.getLeastSignificantBits()); bb.putLong(uuid.getMostSignificantBits()); return bb.array(); } public static UUID[] stringToUuid(String[] uuids) { UUID[] result = new UUID[uuids.length]; for (int i = 0; i < uuids.length; ++i) { result[i] = stringToUuid(uuids[i]); } return result; } public static UUID stringToUuid(String uuidStr) { if (uuidStr.length() == 4) { uuidStr = BASE_UUID_START + uuidStr + BASE_UUID_END; } return UUID.fromString(uuidStr); } }