Skip to content

Instantly share code, notes, and snippets.

@vshank77
Created February 4, 2011 17:47
Show Gist options
  • Save vshank77/811442 to your computer and use it in GitHub Desktop.
Save vshank77/811442 to your computer and use it in GitHub Desktop.
Generate a 6 digit code in Java (case-insensitive)
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