这是一个全球唯一随机字符串,由36个字母数字中划线组。
- 创建UUID:
UUID uuid = UUID.randomUUID();
- 通过截取字符串substring和字符替换replace获得你希望得到的具有唯一性的字符串长度和格式:
System.out.println(uuid.toString().replace("-","").substring(20));
这是一个全球唯一随机字符串,由36个字母数字中划线组。
UUID uuid = UUID.randomUUID();
System.out.println(uuid.toString().replace("-","").substring(20));