import java.util.Random;
public class getfreeStr {
/**
* @param args
* Java获取随机字符串
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(getRandomString(10));
}
public static String getRandomString(int length){
StringBuffer buffer=new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
StringBuffer sb=new StringBuffer();
Random r=new Random();
int range=buffer.length();
for(int i=0;i<length;i++){
sb.append(buffer.charAt(r.nextInt(range)));
}
return sb.toString();
}
}
public class getfreeStr {
/**
* @param args
* Java获取随机字符串
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(getRandomString(10));
}
public static String getRandomString(int length){
StringBuffer buffer=new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
StringBuffer sb=new StringBuffer();
Random r=new Random();
int range=buffer.length();
for(int i=0;i<length;i++){
sb.append(buffer.charAt(r.nextInt(range)));
}
return sb.toString();
}
}