Here you can find the source of generateRandomString(int length)
public static String generateRandomString(int length)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { private static final Random random = new Random(); public static String generateRandomString(int length) { char[] characters = new char[length]; for (int i = 0; i < length; i++) { char start, end; switch (random.nextInt(4)) { case 0: start = 'A'; end = 'Z'; case 1: start = '0'; end = '9'; default: start = 'a'; end = 'z'; }//from w ww .j a v a 2s. c o m characters[i] = (char) (start + random.nextInt(end - start)); } return new String(characters); } }