How to generate random string with no duplicates in java -


i read answers , use set or other data structure ensure there no duplicates. situation , stored lot random string in database , have make sure generated random string should not existed in database .

and don't think retrieve random string database set , generated random string idea...

i found system.currenttimemillis() generate "random" number , how translate number random string question...i need string length 8.

any suggestion appreciated

you can use apache library this: randomstringutils

randomstringutils.randomalphanumeric(8).touppercase() // alphanumeric  randomstringutils.randomalphabetic(8).touppercase() // pure alphabets 

randomalphabetic(int count) creates random string length number of characters specified.

randomalphanumeric(int count) creates random string length number of characters specified.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -