Real quick here. I needed to generate a random string for auto generated passwords. So I was thinking that I was going to have to write some stupid block of code to randomly select characters out of an array.
However, I stumbled upon org.apache.commons.lang.RandomStringUtils.
Then there was this rad method there: RandomStringUtils.random(int len, String chars)
example:
RandomStringUtils.random(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
Exactly what I needed! Thanks Apache Commons for being so RAD!
Go write some code!
Showing posts with label apache commons. Show all posts
Showing posts with label apache commons. Show all posts
Wednesday, June 17, 2009
Subscribe to:
Comments (Atom)