import java.util.Random; 
String random_len(int string_length) {
    chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz123456789"; 
    randomstring =""; 
    for (int i=0; i<string_length; i++) { 
        Random randomGenerator = new Random(); 
        int randomInt = randomGenerator.nextInt(chars.length()); 
        randomstring += chars.substring(randomInt,randomInt+1); 
    } 
    return randomstring;
}
log.info("8位长度:"+random_len(8));
log.info("16位长度:"+random_len(16));
vars.put("random_8", random_len(8));
vars.put("random_16", random_len(16));

标签: 字符, BeanShell, int, java, String, chars, 随机, random, Random

相关文章推荐

添加新评论,含*的栏目为必填