forked from rongchao/epmet-cloud-rizhao
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
792 B
33 lines
792 B
4 years ago
|
package com.epmet;
|
||
|
|
||
|
import com.epmet.commons.tools.constant.StrConstant;
|
||
|
|
||
|
/**
|
||
|
* desc:随机生成字母
|
||
|
*
|
||
|
* @author: LiuJanJun
|
||
|
* @date: 2022/3/1 5:16 下午
|
||
|
* @version: 1.0
|
||
|
*/
|
||
|
public class StringRandomUtils {
|
||
|
|
||
|
public static String getRandomStr(int length){
|
||
|
String result = StrConstant.EPMETY_STR;
|
||
|
//小写字母范围: 97~122
|
||
|
for (int i = 0; i < length; i++) {
|
||
|
int randomNumber = 97 + (int) (Math.random()* (122+1-97));
|
||
|
result += (char)randomNumber;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
StringRandomUtils test = new StringRandomUtils();
|
||
|
//测试
|
||
|
for (int i = 0; i < 1000000; i++) {
|
||
|
System.out.println(getRandomStr(5));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|