36位,a-z字符,要求至少跑一天不会有不重复。privatestaticchar[]str={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'...
36位,a-z字符,要求至少跑一天不会有不重复。
private static char[] str = {'a','b','c','d','e','f','g',
'h','i','j','k','l','m','n',
'o','p','q','r','s','t','u',
'v','w','x','y','z'};
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Set set = new HashSet();
List arr = new ArrayList();
String fileName = "f:\\zyhxx"+".txt";
FileOutputStream fo=new FileOutputStream(fileName);
OutputStreamWriter ow=new OutputStreamWriter(fo,"gbk");
PrintWriter out=new PrintWriter(ow);
int num = 0;
while(true){
StringBuffer buff = new StringBuffer();
for(int i = 0; i < 36; i++){
int m = new Random().nextInt(26);
buff.append(str[m]);
}
String s = buff.toString();
System.out.println((num++)+"\t"+s);
if(arr.contains(s)){
System.out.println(arr.indexOf(s));
System.out.println(s);
break;
}
out.println(s);
arr.add(s);
}
out.close();
}
才100000就重复了
展开