package com.slei.order;
public class Untitled1 {
public String getRandomString(int random, int len) {
java.util.Random rd = new java.util.Random(random);
StringBuffer sb = new StringBuffer();
int rdGet; // 取得随机数
char ch;
for (int i = 0; i < len; i++) {
//rdGet = Math.abs(rd.nextInt()) % 10 + 48; // 产生48到57的随机数(0-9的键位值)
rdGet = Math.abs(rd.nextInt()) % 26 + 97; //产生97到122的随机数(a-z的键位值)
ch = (char) rdGet;
sb.append(ch);
}
return sb.toString();
}
public static void main(String[] args) {
Untitled1 dao = new Untitled1();
System.out.println(dao.getRandomString(2, 16));
System.out.println(dao.getRandomString(3, 16));
}
}
public class Untitled1 {
public String getRandomString(int random, int len) {
java.util.Random rd = new java.util.Random(random);
StringBuffer sb = new StringBuffer();
int rdGet; // 取得随机数
char ch;
for (int i = 0; i < len; i++) {
//rdGet = Math.abs(rd.nextInt()) % 10 + 48; // 产生48到57的随机数(0-9的键位值)
rdGet = Math.abs(rd.nextInt()) % 26 + 97; //产生97到122的随机数(a-z的键位值)
ch = (char) rdGet;
sb.append(ch);
}
return sb.toString();
}
public static void main(String[] args) {
Untitled1 dao = new Untitled1();
System.out.println(dao.getRandomString(2, 16));
System.out.println(dao.getRandomString(3, 16));
}
}