RandomStringUtils generate random numbers

There is a random number tool class RandomStringUtils in the org.apache.commons.lang package, which is a tool class for generating random numbers of a given length according to a specified string array. The accumulator contains many methods, all of which return random number strings. Each method provides at least one parameter int count, which represents the length of the random number to be generated.

//Generate a 5-digit random string, which is garbled in Chinese environment
RandomStringUtils.random(5);

//Use the specified character to generate a 5-digit random string
RandomStringUtils.random(5, new char[]{'a ','b','c','d','e','f', '1', '2', '3'});

//Generate a random combination string of letters and numbers of the specified length
RandomStringUtils.randomAlphanumeric(5);

//Generate a random number string
RandomStringUtils.randomNumeric(5);

//Generate a random [az] string, including case
RandomStringUtils.randomAlphabetic(5);

//Generate from ASCII 32 to 126 The random string
RandomStringUtils.randomAscii(4)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326165347&siteId=291194637