Take a look for RandomStringUtils and RandomUtils. Apache Common-langs make a simple way to do it. RandomUtils is a Utility library that supplement the sandart Random class. RandomStringUtils is an operations for random Strings. Currently private high surrogate characters are ignored. These are Unicode characters that fall between the values 56192 (db80) and 56319 (dbff) as we don’t know how to handle them. High and low surrogates are correctly dealt with – that is if a high surrogate is randomly chosen, 55296 (d800) to 56191 (db7f) then it is followed by a low surrogate. If a low surrogate is chosen, 56320 (dc00) to 57343 (dfff) then it is placed after a randomly chosen high surrogate.
Let see an example in the code snippet below:
And here are the results of our code snippet above: