BeanShell生成随机字符

 

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生成随机字符

上一篇:linux磁盘修复(home或者其他目录无法进入,系统进入emergency mode)


下一篇:Linux 终端命令格式