1 package org.changneng.util;
 2 
 3 import java.util.Random;
 4 public class A {
 5     public static void main(String args[]){
 6              for(int i=0;i<100;i++){
 7                  System.out.println(GetRandomString(10));
 8              }
 9     }
10 
11     public static String GetRandomString(int Len) {
12         
13         String[] baseString={"0","1","2","3",
14                 "4","5","6","7","8","9",
15                 "a","b","c","d","e",
16                 "f","g","h","i","j",
17                 "k","l","m","n","o",
18                 "p","q","r","s","t",
19                 "u","v","w","x","y",
20                 "z","A","B","C","D",
21                 "E","F","G","H","I",
22                 "J","K","L","M","N",
23                 "O","P","Q","R","S",
24                 "T","U","V","W","X","Y","Z"};
25         Random random = new Random();
26         int length=baseString.length;
27         String randomString="";
28         for(int i=0;i<length;i++){
29             randomString+=baseString[random.nextInt(length)];
30         }
31         random = new Random(System.currentTimeMillis());
32         String resultStr="";
33         for (int i = 0; i < Len; i++) {
34             resultStr += randomString.charAt(random.nextInt(randomString.length()-1));
35         }
36         return resultStr;
37     }
38 
39 }

 

posted on 2016-03-18 14:11  Sharpest  阅读(6810)  评论(0编辑  收藏  举报