Here you can find the source of generateRandomString(Random rnd, char[] alphabet, int maxLength)
public static String generateRandomString(Random rnd, char[] alphabet, int maxLength)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static String generateRandomString(Random rnd, char[] alphabet, int maxLength) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < (rnd.nextInt(maxLength) + 1); i++) { sb.append(alphabet[rnd.nextInt(alphabet.length)]); }// ww w .j av a 2s . c om return sb.toString(); } }