Here you can find the source of getRandomStr(int length)
public static String getRandomStr(int length)
//package com.java2s; import java.util.Random; public class Main { private static final StringBuffer characters = new StringBuffer( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); public static String getRandomStr(int length) { StringBuffer sbf = new StringBuffer(); Random rand = new Random(); int charSize = characters.length(); for (int i = 0; i < length; i++) { sbf.append(characters.charAt(rand.nextInt(charSize))); }/* w ww . jav a 2s. c om*/ return sbf.toString(); } }