随机生成不重复的字符串

public static String shuffleForSortingString(String begin ,String end) {
    String uuid = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
    Long randomNum =  System.currentTimeMillis();
    String str = uuid+randomNum;
    char[] c = str.toCharArray();
    List<Character> lst = new ArrayList<Character>();
    for (int i = 0; i < c.length; i++) {
        lst.add(c[i]);
    }
    //打乱顺序
    Collections.shuffle(lst);

    String resultStr = "";
    for (int i = 0; i < lst.size(); i++) {
        resultStr += lst.get(i);
    }
    return resultStr.substring(begin,end).trim();
}
上一篇:HttpClient工具栏


下一篇:javascript中的字符串首字母转大写,字符串反转