标签:number string 固定 tostring turn int public def tran
java中选择相应的字段,生成固定长度的字符串
public static String getRandomString(int length) { // length表示生成字符串的长度
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
标签:number string 固定 tostring turn int public def tran
原文地址:https://www.cnblogs.com/qqzhulu/p/10211960.html