能不能用ramdom()类产生汉字、英语字母、数字、符号综合的验证码
解决方案 »
- 定义MVC的时候 为什么老定义类BusinessService这个类 还有为什么要定义代理类 谁举个例子给我讲讲啊 谢谢
- FirstJsp 出现问题 在线等
- 急求!!!用java写个算法怎样把薪水相同的人的名字打印出来
- java程序员的困惑,请求各位多多提意见
- HttpSessionListener 调用 spring 中服务类的实现方法
- Hibernate怎么动态修改hbm.xml中table的名字?
- 简单点说!求pet store或者jive的下载地址(分不够可再另开贴加分)
- 我用MyEclipse在tomcat下的一个web里用了Logging 它记录的错误日志文件放在哪里
- 类型转换
- 请各位大侠给点建议
- myEclipse快捷键错误
- logic:iterate 计算问题新手,请教
private static final char[] CODERANDOM = "零壹贰叁肆伍陆柒捌玖abcdefg123456789+-*/=".toCharArray();
{
Random random = new Random(System.currentTimeMillis());
// random.next
char c1 = '人';
char c2 = '鸟';
int n1 = c2-c1;//中文
int n2 = 90- 65;//大写字母
int n3 = 122-97;
StringBuffer sb = new StringBuffer();
for(int i=0;i<5;i++){
switch(random.nextInt(4))
{
case 0://中文
sb.append((char)(c1+random.nextInt(n1)));
break;
case 1://数字
sb.append(random.nextInt(10));
break;
case 2://大写字母
sb.append((char)(65+random.nextInt(n2)));
break;
case 3://小写字母
sb.append((char)(97+random.nextInt(n3)));
}
}
System.out.println(sb);
}写的玩,发现这种方法出来的汉字不是 随便一个人都能打出来的