//产生5位长度的随机字符串,中文环境下是乱码
RandomStringUtils.random(5);
//使用指定的字符生成5位长度的随机字符串
RandomStringUtils.random(5, new char[]{‘a’,‘b’,‘c’,‘d’,‘e’,‘f’, ‘1’, ‘2’, ‘3’});
//生成指定长度的字母和数字的随机组合字符串
RandomStringUtils.randomAlphanumeric(5);
//生成随机数字字符串
RandomStringUtils.randomNumeric(5);
//生成随机[a-z]字符串,包含大小写
RandomStringUtils.randomAlphabetic(5);
//生成从ASCII 32到126组成的随机字符串
RandomStringUtils.randomAscii(4)
复制代码
1、random(int count) //在所有字符中随机生成6位
2、randomAscii(int count) //在ASCII表中的打印字符中,即ASCII表32-127中随机生成6位
3、randomAlphabetic(int count) // 生成只有字母的随机字符串,但是此方法的效率不高,不建议这样使用
4、randomAlphanumeric(int count) //生成只有字母和数字的随机字符串,同样不建议这样使用
5、randomNumeric(int count) // 生成只有数字的随机字符串,
6、random(int count, boolean letters, boolean numbers) //可以指定是否要限定只生成字母或数字,上述三个方法都是调用此方法
7、random(int count, int start, int end, boolean letters, boolean numbers) //可以指定字符集开始的位置,即不用搜索所有全部字符,同时可指定是否指定是否只生成字母或数字
8、random(int count, int start, int end, boolean letters, boolean numbers, char[] chars) //用指定的字符集生成字符串
9、random(int count, String chars) //使用指定字符串的字符生成新的随机字符串
10、String random(int count, char[] chars) //用指定的字符集生成字符串,只是不能指定letters和numbers,其实还是调用了8