标签:
1.生成四位随机不重复验证码
//生成一个四位不重复的随机码 public static String get4Codes(){ StringBuffer sb = new StringBuffer(); String codes = "qwertyuiopasdfghjklzxcvbnm0123456789"; Random random = new Random(); for (int i =0; i< codes.length(); i++){ char c = codes.charAt(random.nextInt(codes.length())); if (sb.length() == 4) break; if (!sb.toString().contains(c+"")) sb.append(c); } return sb.toString(); }
标签:
原文地址:http://www.cnblogs.com/bravolove/p/5796155.html