Created
February 4, 2011 17:47
-
-
Save vshank77/811442 to your computer and use it in GitHub Desktop.
Generate a 6 digit code in Java (case-insensitive)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String getUniquedId(BloomFilter<String> filter) { | |
String uid = getStringUid(); | |
while(filter.contains(uid)) { | |
uid = getStringUid(); | |
} | |
filter.add(uid); | |
return uid; | |
} | |
private static String getStringUid() { | |
UUID uid2 = UUID.randomUUID(); | |
return uid2.toString().substring(0, 6); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment