首页 > 其他 > 详细

获取随机字符串

时间:2018-02-06 13:50:14      阅读:227      评论:0      收藏:0      [点我收藏+]
public class RandStrUtil {
  public final static String EN_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  public final static String EN_LOWER = "abcdefghijklmnopqrstuvwxyz";
  public final static String NUM = "1234567890";
  //获取大写的方法,其他相同
  public static String getEnUpper(int strLen) {
    Random r=new Random();
    String Upper="";
    for(int i=0;i<strLen;i++){
      Upper+=EN_UPPER.charAt(r.nextInt(EN_UPPER.length()));
    }
    return Upper;
  }
}

获取随机字符串

原文:https://www.cnblogs.com/IceBlueBrother/p/8421737.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!