Here you can find the source of randomString(Random r, int minCount, int maxCount)
public static String randomString(Random r, int minCount, int maxCount)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static String randomString(Random r, int minCount, int maxCount) { minCount = Math.max(Math.min(minCount, maxCount), 1); maxCount = Math.max(minCount, maxCount); final int stringCount = minCount + r.nextInt(maxCount - minCount); char[] s = new char[stringCount]; for (int i = 0; i < stringCount; ++i) { s[i] = (char) (32 + r.nextInt(127 - 32)); }//from w w w .j a v a2 s. c o m return new String(s); } }