生成验证码之工具类
package cn.edu.dcxy; import java.util.Random; public class ItUtil { /** * 由于工具类无需创建对象,所以把其构造器私有化 */ private ItUtil(){ } public static String createVerifyCode(int n) { String code = ""; String data = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random r = new Random(); for (int i = 0; i < n; i++) { int index = r.nextInt(data.length()); code += data.charAt(index); } return code; } }
标签:code,java,String,int,验证码,工具,data From: https://www.cnblogs.com/zhzhang/p/16912235.html