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 - Unable to make sub reports with Jasper -

sql - The object name contains more than the maximum number of prefixes. The maximum is 2 -

Java Web Service Soap fault exception client -