Java获取UUID工具类
import java.util.UUID;
public class UUIDGenerator {
public UUIDGenerator() {
}
//获取不带"-"的UUID
public static String getUUID() {
UUID uuid = UUID.randomUUID();
String str = uuid.toString();
// 去掉"-"符号
String temp = str.replace("-", "");
return temp;
}
//获得指定数量的UUID
public static String[] getUUID(int number) {
if (number < 1) {
return null;
}
String[] uuid = new String[number];
for (int i = 0; i < number; i++) {
uuid[i] = getUUID();
System.out.println(uuid[i]);
}
return uuid;
}
}