public class RandomStringUtil {
private static final int n=42;
public static String getRandomStr(){
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random r = new Random();//创建random对象
StringBuffer buff = new StringBuffer();//StringBuffer
for (int i = 0; i < n; i++) {
int it = r.nextInt(62);//使用random生成[0,62)之间的随机数,不包括62
buff.append(str.charAt(it));// 把int下标 转为 str中随机字符(数字,大写字母或者小写字母)
}
buff.insert(10,"-");
return buff.toString();
}
}
02-11
569
02-08
499
02-17
1529
11-08
337
11-06
638