日期:2014-05-20 浏览次数:20688 次
str1=GetRandomCharString("");; str3=GetRandomCharString(str1);; private String GetRandomCharString(String strExclude){ Random randGen = null; char[] numbersAndLetters = null; if (randGen == null) { randGen = new Random(); numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); } char randC; String randStr=""; randC = numbersAndLetters[randGen.nextInt(61)]; randStr=String.valueOf(randC); while(strExclude.indexOf(randStr)>0){ randC = numbersAndLetters[randGen.nextInt(61)]; randStr=String.valueOf(randC); } return randStr; }