Here you can find the source of generateString(Random rng, String characters, int length)
private static String generateString(Random rng, String characters, int length)
//package com.java2s; //License from project: Apache License import java.util.Random; import java.util.concurrent.ThreadLocalRandom; public class Main { private static String generateString(Random rng, String characters, int length) { char[] text = new char[length]; for (int i = 0; i < length; i++) { text[i] = characters.charAt(rng.nextInt(characters.length())); }//from ww w . j av a 2 s .com return new String(text); } public static String generateString(int length) { return generateString(ThreadLocalRandom.current(), "abcdefghi123456zxcv", length); } }