Here you can find the source of genRandomString(int count)
public static String genRandomString(int count)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static final char[] DEFAULT_CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', }; public static String genRandomString(int count) { return genRandomString(count, DEFAULT_CHARS); }//w ww .j av a 2 s . co m public static String genRandomString(int count, char[] elements) { StringBuffer sb = new StringBuffer(); int len = elements.length - 1; for (int i = 0; i < count; i++) { sb.append(elements[new Random(System.nanoTime()).nextInt(len)]); } return sb.toString(); } }