Here you can find the source of generateString(String alphabet, int length)
public static String generateString(String alphabet, int length)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static final Random random = new Random(); public static String generateString(String alphabet, int length) { if (alphabet.length() == 0) return null; StringBuilder ret = new StringBuilder(length); for (int i = 0; i < length; ++i) ret.append(alphabet.charAt(random.nextInt(alphabet.length()))); return ret.toString(); }// w w w.java2 s . c om }