Here you can find the source of generateString(String charSet, int len)
public static String generateString(String charSet, int len)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static String generateString(String charSet, int len) { return generateString(charSet, len, len); }/*ww w .j a va 2 s. c o m*/ public static String generateString(String charSet, int minLen, int maxLen) { Random rng = new Random(); int len = minLen; if ((maxLen - minLen) > 0) { len += rng.nextInt(maxLen - minLen); } char[] text = new char[len]; for (int i = 0; i < len; i++) { text[i] = charSet.charAt(rng.nextInt(charSet.length())); } return new String(text); } }