java根据长度获取不带“-”的UUID
public static String getSimpleUUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
public static String getSimpleUUID(int len) {
if (0 >= len) {
return null;
}
String uuid = getSimpleUUID();
if (len >= uuid.length()) {
return uuid;
}
StringBuilder str = new StringBuilder();
for (int i = 0; i < len; i++) {
str.append(uuid.charAt(i));
}
return str.toString();
}