Here you can find the source of genRandomString()
public static String genRandomString()
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.List; import java.util.concurrent.ThreadLocalRandom; public class Main { public static String genRandomString() { int len = getRandomInt(23) + 1; List<Integer> asciiBase = Arrays.asList(65, 97); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { int randChar = getRandomInt(26); sb.append(Character.toChars(randChar + asciiBase.get(getRandomInt(asciiBase.size())))); }/*from www . j a v a2s .c o m*/ return sb.toString(); } public static int getRandomInt(int n) { return getThreadLocalRandom().nextInt(n); } public static ThreadLocalRandom getThreadLocalRandom() { return ThreadLocalRandom.current(); } }