Here you can find the source of generateString(int length)
public static String generateString(int length)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ThreadLocalRandom; public class Main { public static final String allChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static String generateString(int length) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { int index = ThreadLocalRandom.current().nextInt(allChar.length()); sb.append(allChar.charAt(index)); }/*from w w w . j a v a 2 s .c o m*/ return sb.toString(); } }