我想了解JAVA中的GUID。 GUID是否可以包含空格?
我正在使用以下代码
import java.util.UUID;
UUID uuid = UUID.randomUUID();
String randomUUIDString = uuid.toString();
randomUUIDString
可以包含空格吗?如果是的话有什么机会避免它?
答案 0 :(得分:6)
没有。来自UUID.toString()
UUID字符串表示如此BNF所述:
UUID = <time_low> "-" <time_mid> "-" <time_high_and_version> "-" <variant_and_sequence> "-" <node> time_low = 4*<hexOctet> time_mid = 2*<hexOctet> time_high_and_version = 2*<hexOctet> variant_and_sequence = 2*<hexOctet> node = 6*<hexOctet> hexOctet = <hexDigit><hexDigit> hexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"
如您所见,返回字符串中的每个字符都是A-F,a-f,0-9或' - '中的字符。