生成随机字符串
/**
* 生成随机字符串
* @param str 字符池
* @param length 随机字符串长度
* @return 生成的随机字符串
*/
public static String randomString(int length,String str) {
//字符池
str = "0EkFaGlH1ImJbKnL2MoNcOpP3QqRdSrT4UsVeWtX5YuZfv6wgx7yhz8AiB9CjD";
//结果
StringBuffer result = new StringBuffer();
for (int i = 0; i < length; i++) {
int index = (int) (Math.random() * str.length());
result.append(str.charAt(index));
}
return result.toString();
}