Commit 0af04a6e by guojuxing

生成随机数工具类

parent 83779fca
......@@ -3,13 +3,13 @@ package com.gic.enterprise.utils;
import java.util.Random;
/**
* 随机生成字母、数字参合的密码
* 生成随机数工具类
* @ClassName: CreatePasswordAutoUtils

* @Description: 

* @author guojuxing

* @date 2019/8/9 4:39 PM

*/
public class CreatePasswordAutoUtils {
public class CreateRandomUtils {
/**
* 随机生成字母、数字参合的密码
* @param length 生成多少位数的密码
......@@ -33,4 +33,22 @@ public class CreatePasswordAutoUtils {
}
return val;
}
/**
* 随机生成0-9的数字
* @Title: generateNumberStr

* @Description:

 * @author guojuxing
* @param length
 生成多少位数
* @return java.lang.String


 */
public static String generateNumberStr(int length) {
String numberChar = "0123456789";
StringBuilder sb = new StringBuilder();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(numberChar.charAt(random.nextInt(numberChar.length())));
}
return sb.toString();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<module version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment