public String getRandNum(int charCount) {
String charValue = "";
for (int i = 0; i < charCount; i++) {
char c = (char) (randomInt(0, 10) + '0');
charValue += String.valueOf(c);
}
return charValue;
}
public int randomInt(int from, int to) {
Random r = new Random();
return from + r.nextInt(to - from);
}
加油吧
Java生成六位验证码(发短信验证)
最新推荐文章于 2024-09-22 19:59:31 发布