How big is the chance to get a Java UUID.randomUUID collision? [duplicate]
问题 This question already has answers here : How good is Java's UUID.randomUUID? (10 answers) Closed 5 years ago . I need to create some uniques files in Java and i plan to use UUID.randomUUID to generate their names. Is there any chance to get a collision for this? Should i do something like bellow os I shouldn't worry about this? Integer attemptsToGenerateUUID = 1; while (true) { UUID fileUUID = UUID.randomUUID(); if (fileDoesNotExistwith this UUID name) { save file; break; }